[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71S3XFC6A9M9PWMZ5RRT2KS":3,"skill-same:01M71S3XFC6A9M9PWMZ5RRT2KS":69},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":43,"linkOnly":44,"markdownContent":45,"markdownBody":46,"frontMatter":47,"refName":48,"commitSha":49,"skillDirectory":50,"forksCount":51,"repositoryHtmlUrl":52,"repositoryHomepageUrl":6,"ownerHtmlUrl":53,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":54,"install":55,"resources":68},"01M71S3XFC6A9M9PWMZ5RRT2KS","V3 Core Implementation",null,"Core module implementation for claude-flow v3. Implements DDD domains, clean architecture patterns, dependency injection, and modular TypeScript codebase with comprehensive testing.","manykarim\u002Frobotframework-agentguard","manykarim","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F61293164?v=4","01M71S15ZAXR15JHKM1N7BHT21","Many Kasiriha","01M71S160CWQXETSCYWXDVNYJ2",1,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fmanykarim\u002Frobotframework-agentguard\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fv3-core-implementation\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",[24,25,5,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42],"v3","core","implementation","dependency","for","domains","module","dependency injection","clean architecture","patterns","clean","testing","injection","architecture patterns","flow","ddd","modular","architecture","typescript","2026-11-10 13:02:02",false,"---\nname: \"V3 Core Implementation\"\ndescription: \"Core module implementation for claude-flow v3. Implements DDD domains, clean architecture patterns, dependency injection, and modular TypeScript codebase with comprehensive testing.\"\n---\n\n# V3 Core Implementation\n\n## What This Skill Does\n\nImplements the core TypeScript modules for claude-flow v3 following Domain-Driven Design principles, clean architecture patterns, and modern TypeScript best practices with comprehensive test coverage.\n\n## Quick Start\n\n```bash\n# Initialize core implementation\nTask(\"Core foundation\", \"Set up DDD domain structure and base classes\", \"core-implementer\")\n\n# Domain implementation (parallel)\nTask(\"Task domain\", \"Implement task management domain with entities and services\", \"core-implementer\")\nTask(\"Session domain\", \"Implement session management domain\", \"core-implementer\")\nTask(\"Health domain\", \"Implement health monitoring domain\", \"core-implementer\")\n```\n\n## Core Implementation Architecture\n\n### Domain Structure\n```\nsrc\u002F\n├── core\u002F\n│   ├── kernel\u002F                     # Microkernel pattern\n│   │   ├── claude-flow-kernel.ts\n│   │   ├── domain-registry.ts\n│   │   └── plugin-loader.ts\n│   │\n│   ├── domains\u002F                    # DDD Bounded Contexts\n│   │   ├── task-management\u002F\n│   │   │   ├── entities\u002F\n│   │   │   ├── value-objects\u002F\n│   │   │   ├── services\u002F\n│   │   │   ├── repositories\u002F\n│   │   │   └── events\u002F\n│   │   │\n│   │   ├── session-management\u002F\n│   │   ├── health-monitoring\u002F\n│   │   ├── lifecycle-management\u002F\n│   │   └── event-coordination\u002F\n│   │\n│   ├── shared\u002F                     # Shared kernel\n│   │   ├── domain\u002F\n│   │   │   ├── entity.ts\n│   │   │   ├── value-object.ts\n│   │   │   ├── domain-event.ts\n│   │   │   └── aggregate-root.ts\n│   │   │\n│   │   ├── infrastructure\u002F\n│   │   │   ├── event-bus.ts\n│   │   │   ├── dependency-container.ts\n│   │   │   └── logger.ts\n│   │   │\n│   │   └── types\u002F\n│   │       ├── common.ts\n│   │       ├── errors.ts\n│   │       └── interfaces.ts\n│   │\n│   └── application\u002F                # Application services\n│       ├── use-cases\u002F\n│       ├── commands\u002F\n│       ├── queries\u002F\n│       └── handlers\u002F\n```\n\n## Base Domain Classes\n\n### Entity Base Class\n```typescript\n\u002F\u002F src\u002Fcore\u002Fshared\u002Fdomain\u002Fentity.ts\nexport abstract class Entity\u003CT> {\n  protected readonly _id: T;\n  private _domainEvents: DomainEvent[] = [];\n\n  constructor(id: T) {\n    this._id = id;\n  }\n\n  get id(): T {\n    return this._id;\n  }\n\n  public equals(object?: Entity\u003CT>): boolean {\n    if (object == null || object == undefined) {\n      return false;\n    }\n\n    if (this === object) {\n      return true;\n    }\n\n    if (!(object instanceof Entity)) {\n      return false;\n    }\n\n    return this._id === object._id;\n  }\n\n  protected addDomainEvent(domainEvent: DomainEvent): void {\n    this._domainEvents.push(domainEvent);\n  }\n\n  public getUncommittedEvents(): DomainEvent[] {\n    return this._domainEvents;\n  }\n\n  public markEventsAsCommitted(): void {\n    this._domainEvents = [];\n  }\n}\n```\n\n### Value Object Base Class\n```typescript\n\u002F\u002F src\u002Fcore\u002Fshared\u002Fdomain\u002Fvalue-object.ts\nexport abstract class ValueObject\u003CT> {\n  protected readonly props: T;\n\n  constructor(props: T) {\n    this.props = Object.freeze(props);\n  }\n\n  public equals(object?: ValueObject\u003CT>): boolean {\n    if (object == null || object == undefined) {\n      return false;\n    }\n\n    if (this === object) {\n      return true;\n    }\n\n    return JSON.stringify(this.props) === JSON.stringify(object.props);\n  }\n\n  get value(): T {\n    return this.props;\n  }\n}\n```\n\n### Aggregate Root\n```typescript\n\u002F\u002F src\u002Fcore\u002Fshared\u002Fdomain\u002Faggregate-root.ts\nexport abstract class AggregateRoot\u003CT> extends Entity\u003CT> {\n  private _version: number = 0;\n\n  get version(): number {\n    return this._version;\n  }\n\n  protected incrementVersion(): void {\n    this._version++;\n  }\n\n  public applyEvent(event: DomainEvent): void {\n    this.addDomainEvent(event);\n    this.incrementVersion();\n  }\n}\n```\n\n## Task Management Domain Implementation\n\n### Task Entity\n```typescript\n\u002F\u002F src\u002Fcore\u002Fdomains\u002Ftask-management\u002Fentities\u002Ftask.entity.ts\nimport { AggregateRoot } from '..\u002F..\u002F..\u002Fshared\u002Fdomain\u002Faggregate-root';\nimport { TaskId } from '..\u002Fvalue-objects\u002Ftask-id.vo';\nimport { TaskStatus } from '..\u002Fvalue-objects\u002Ftask-status.vo';\nimport { Priority } from '..\u002Fvalue-objects\u002Fpriority.vo';\nimport { TaskAssignedEvent } from '..\u002Fevents\u002Ftask-assigned.event';\n\ninterface TaskProps {\n  id: TaskId;\n  description: string;\n  priority: Priority;\n  status: TaskStatus;\n  assignedAgentId?: string;\n  createdAt: Date;\n  updatedAt: Date;\n}\n\nexport class Task extends AggregateRoot\u003CTaskId> {\n  private props: TaskProps;\n\n  private constructor(props: TaskProps) {\n    super(props.id);\n    this.props = props;\n  }\n\n  static create(description: string, priority: Priority): Task {\n    const task = new Task({\n      id: TaskId.create(),\n      description,\n      priority,\n      status: TaskStatus.pending(),\n      createdAt: new Date(),\n      updatedAt: new Date()\n    });\n\n    return task;\n  }\n\n  static reconstitute(props: TaskProps): Task {\n    return new Task(props);\n  }\n\n  public assignTo(agentId: string): void {\n    if (this.props.status.equals(TaskStatus.completed())) {\n      throw new Error('Cannot assign completed task');\n    }\n\n    this.props.assignedAgentId = agentId;\n    this.props.status = TaskStatus.assigned();\n    this.props.updatedAt = new Date();\n\n    this.applyEvent(new TaskAssignedEvent(\n      this.id.value,\n      agentId,\n      this.props.priority\n    ));\n  }\n\n  public complete(result: TaskResult): void {\n    if (!this.props.assignedAgentId) {\n      throw new Error('Cannot complete unassigned task');\n    }\n\n    this.props.status = TaskStatus.completed();\n    this.props.updatedAt = new Date();\n\n    this.applyEvent(new TaskCompletedEvent(\n      this.id.value,\n      result,\n      this.calculateDuration()\n    ));\n  }\n\n  \u002F\u002F Getters\n  get description(): string { return this.props.description; }\n  get priority(): Priority { return this.props.priority; }\n  get status(): TaskStatus { return this.props.status; }\n  get assignedAgentId(): string | undefined { return this.props.assignedAgentId; }\n  get createdAt(): Date { return this.props.createdAt; }\n  get updatedAt(): Date { return this.props.updatedAt; }\n\n  private calculateDuration(): number {\n    return this.props.updatedAt.getTime() - this.props.createdAt.getTime();\n  }\n}\n```\n\n### Task Value Objects\n```typescript\n\u002F\u002F src\u002Fcore\u002Fdomains\u002Ftask-management\u002Fvalue-objects\u002Ftask-id.vo.ts\nexport class TaskId extends ValueObject\u003Cstring> {\n  private constructor(value: string) {\n    super({ value });\n  }\n\n  static create(): TaskId {\n    return new TaskId(crypto.randomUUID());\n  }\n\n  static fromString(id: string): TaskId {\n    if (!id || id.length === 0) {\n      throw new Error('TaskId cannot be empty');\n    }\n    return new TaskId(id);\n  }\n\n  get value(): string {\n    return this.props.value;\n  }\n}\n\n\u002F\u002F src\u002Fcore\u002Fdomains\u002Ftask-management\u002Fvalue-objects\u002Ftask-status.vo.ts\ntype TaskStatusType = 'pending' | 'assigned' | 'in_progress' | 'completed' | 'failed';\n\nexport class TaskStatus extends ValueObject\u003CTaskStatusType> {\n  private constructor(status: TaskStatusType) {\n    super({ value: status });\n  }\n\n  static pending(): TaskStatus { return new TaskStatus('pending'); }\n  static assigned(): TaskStatus { return new TaskStatus('assigned'); }\n  static inProgress(): TaskStatus { return new TaskStatus('in_progress'); }\n  static completed(): TaskStatus { return new TaskStatus('completed'); }\n  static failed(): TaskStatus { return new TaskStatus('failed'); }\n\n  get value(): TaskStatusType {\n    return this.props.value;\n  }\n\n  public isPending(): boolean { return this.value === 'pending'; }\n  public isAssigned(): boolean { return this.value === 'assigned'; }\n  public isInProgress(): boolean { return this.value === 'in_progress'; }\n  public isCompleted(): boolean { return this.value === 'completed'; }\n  public isFailed(): boolean { return this.value === 'failed'; }\n}\n\n\u002F\u002F src\u002Fcore\u002Fdomains\u002Ftask-management\u002Fvalue-objects\u002Fpriority.vo.ts\ntype PriorityLevel = 'low' | 'medium' | 'high' | 'critical';\n\nexport class Priority extends ValueObject\u003CPriorityLevel> {\n  private constructor(level: PriorityLevel) {\n    super({ value: level });\n  }\n\n  static low(): Priority { return new Priority('low'); }\n  static medium(): Priority { return new Priority('medium'); }\n  static high(): Priority { return new Priority('high'); }\n  static critical(): Priority { return new Priority('critical'); }\n\n  get value(): PriorityLevel {\n    return this.props.value;\n  }\n\n  public getNumericValue(): number {\n    const priorities = { low: 1, medium: 2, high: 3, critical: 4 };\n    return priorities[this.value];\n  }\n}\n```\n\n## Domain Services\n\n### Task Scheduling Service\n```typescript\n\u002F\u002F src\u002Fcore\u002Fdomains\u002Ftask-management\u002Fservices\u002Ftask-scheduling.service.ts\nimport { Injectable } from '..\u002F..\u002F..\u002Fshared\u002Finfrastructure\u002Fdependency-container';\nimport { Task } from '..\u002Fentities\u002Ftask.entity';\nimport { Priority } from '..\u002Fvalue-objects\u002Fpriority.vo';\n\n@Injectable()\nexport class TaskSchedulingService {\n  public prioritizeTasks(tasks: Task[]): Task[] {\n    return tasks.sort((a, b) =>\n      b.priority.getNumericValue() - a.priority.getNumericValue()\n    );\n  }\n\n  public canSchedule(task: Task, agentCapacity: number): boolean {\n    if (agentCapacity \u003C= 0) return false;\n\n    \u002F\u002F Critical tasks always schedulable\n    if (task.priority.equals(Priority.critical())) return true;\n\n    \u002F\u002F Other logic based on capacity\n    return true;\n  }\n\n  public calculateEstimatedDuration(task: Task): number {\n    \u002F\u002F Simple heuristic - would use ML in real implementation\n    const baseTime = 300000; \u002F\u002F 5 minutes\n    const priorityMultiplier = {\n      low: 0.5,\n      medium: 1.0,\n      high: 1.5,\n      critical: 2.0\n    };\n\n    return baseTime * priorityMultiplier[task.priority.value];\n  }\n}\n```\n\n## Repository Interfaces & Implementations\n\n### Task Repository Interface\n```typescript\n\u002F\u002F src\u002Fcore\u002Fdomains\u002Ftask-management\u002Frepositories\u002Ftask.repository.ts\nexport interface ITaskRepository {\n  save(task: Task): Promise\u003Cvoid>;\n  findById(id: TaskId): Promise\u003CTask | null>;\n  findByAgentId(agentId: string): Promise\u003CTask[]>;\n  findByStatus(status: TaskStatus): Promise\u003CTask[]>;\n  findPendingTasks(): Promise\u003CTask[]>;\n  delete(id: TaskId): Promise\u003Cvoid>;\n}\n```\n\n### SQLite Implementation\n```typescript\n\u002F\u002F src\u002Fcore\u002Fdomains\u002Ftask-management\u002Frepositories\u002Fsqlite-task.repository.ts\n@Injectable()\nexport class SqliteTaskRepository implements ITaskRepository {\n  constructor(\n    @Inject('Database') private db: Database,\n    @Inject('Logger') private logger: ILogger\n  ) {}\n\n  async save(task: Task): Promise\u003Cvoid> {\n    const sql = `\n      INSERT OR REPLACE INTO tasks (\n        id, description, priority, status, assigned_agent_id, created_at, updated_at\n      ) VALUES (?, ?, ?, ?, ?, ?, ?)\n    `;\n\n    await this.db.run(sql, [\n      task.id.value,\n      task.description,\n      task.priority.value,\n      task.status.value,\n      task.assignedAgentId,\n      task.createdAt.toISOString(),\n      task.updatedAt.toISOString()\n    ]);\n\n    this.logger.debug(`Task saved: ${task.id.value}`);\n  }\n\n  async findById(id: TaskId): Promise\u003CTask | null> {\n    const sql = 'SELECT * FROM tasks WHERE id = ?';\n    const row = await this.db.get(sql, [id.value]);\n\n    return row ? this.mapRowToTask(row) : null;\n  }\n\n  async findPendingTasks(): Promise\u003CTask[]> {\n    const sql = 'SELECT * FROM tasks WHERE status = ? ORDER BY priority DESC, created_at ASC';\n    const rows = await this.db.all(sql, ['pending']);\n\n    return rows.map(row => this.mapRowToTask(row));\n  }\n\n  private mapRowToTask(row: any): Task {\n    return Task.reconstitute({\n      id: TaskId.fromString(row.id),\n      description: row.description,\n      priority: Priority.fromString(row.priority),\n      status: TaskStatus.fromString(row.status),\n      assignedAgentId: row.assigned_agent_id,\n      createdAt: new Date(row.created_at),\n      updatedAt: new Date(row.updated_at)\n    });\n  }\n}\n```\n\n## Application Layer\n\n### Use Case Implementation\n```typescript\n\u002F\u002F src\u002Fcore\u002Fapplication\u002Fuse-cases\u002Fassign-task.use-case.ts\n@Injectable()\nexport class AssignTaskUseCase {\n  constructor(\n    @Inject('TaskRepository') private taskRepository: ITaskRepository,\n    @Inject('AgentRepository') private agentRepository: IAgentRepository,\n    @Inject('DomainEventBus') private eventBus: DomainEventBus,\n    @Inject('Logger') private logger: ILogger\n  ) {}\n\n  async execute(command: AssignTaskCommand): Promise\u003CAssignTaskResult> {\n    try {\n      \u002F\u002F 1. Validate command\n      await this.validateCommand(command);\n\n      \u002F\u002F 2. Load aggregates\n      const task = await this.taskRepository.findById(command.taskId);\n      if (!task) {\n        throw new TaskNotFoundError(command.taskId);\n      }\n\n      const agent = await this.agentRepository.findById(command.agentId);\n      if (!agent) {\n        throw new AgentNotFoundError(command.agentId);\n      }\n\n      \u002F\u002F 3. Business logic\n      if (!agent.canAcceptTask(task)) {\n        throw new AgentCannotAcceptTaskError(command.agentId, command.taskId);\n      }\n\n      task.assignTo(command.agentId);\n      agent.acceptTask(task.id);\n\n      \u002F\u002F 4. Persist changes\n      await Promise.all([\n        this.taskRepository.save(task),\n        this.agentRepository.save(agent)\n      ]);\n\n      \u002F\u002F 5. Publish domain events\n      const events = [\n        ...task.getUncommittedEvents(),\n        ...agent.getUncommittedEvents()\n      ];\n\n      for (const event of events) {\n        await this.eventBus.publish(event);\n      }\n\n      task.markEventsAsCommitted();\n      agent.markEventsAsCommitted();\n\n      \u002F\u002F 6. Return result\n      this.logger.info(`Task ${command.taskId.value} assigned to agent ${command.agentId}`);\n\n      return AssignTaskResult.success({\n        taskId: task.id,\n        agentId: command.agentId,\n        assignedAt: new Date()\n      });\n\n    } catch (error) {\n      this.logger.error(`Failed to assign task ${command.taskId.value}:`, error);\n      return AssignTaskResult.failure(error);\n    }\n  }\n\n  private async validateCommand(command: AssignTaskCommand): Promise\u003Cvoid> {\n    if (!command.taskId) {\n      throw new ValidationError('Task ID is required');\n    }\n    if (!command.agentId) {\n      throw new ValidationError('Agent ID is required');\n    }\n  }\n}\n```\n\n## Dependency Injection Setup\n\n### Container Configuration\n```typescript\n\u002F\u002F src\u002Fcore\u002Fshared\u002Finfrastructure\u002Fdependency-container.ts\nimport { Container } from 'inversify';\nimport { TYPES } from '.\u002Ftypes';\n\nexport class DependencyContainer {\n  private container: Container;\n\n  constructor() {\n    this.container = new Container();\n    this.setupBindings();\n  }\n\n  private setupBindings(): void {\n    \u002F\u002F Repositories\n    this.container.bind\u003CITaskRepository>(TYPES.TaskRepository)\n      .to(SqliteTaskRepository)\n      .inSingletonScope();\n\n    this.container.bind\u003CIAgentRepository>(TYPES.AgentRepository)\n      .to(SqliteAgentRepository)\n      .inSingletonScope();\n\n    \u002F\u002F Services\n    this.container.bind\u003CTaskSchedulingService>(TYPES.TaskSchedulingService)\n      .to(TaskSchedulingService)\n      .inSingletonScope();\n\n    \u002F\u002F Use Cases\n    this.container.bind\u003CAssignTaskUseCase>(TYPES.AssignTaskUseCase)\n      .to(AssignTaskUseCase)\n      .inSingletonScope();\n\n    \u002F\u002F Infrastructure\n    this.container.bind\u003CILogger>(TYPES.Logger)\n      .to(ConsoleLogger)\n      .inSingletonScope();\n\n    this.container.bind\u003CDomainEventBus>(TYPES.DomainEventBus)\n      .to(InMemoryDomainEventBus)\n      .inSingletonScope();\n  }\n\n  get\u003CT>(serviceIdentifier: symbol): T {\n    return this.container.get\u003CT>(serviceIdentifier);\n  }\n\n  bind\u003CT>(serviceIdentifier: symbol): BindingToSyntax\u003CT> {\n    return this.container.bind\u003CT>(serviceIdentifier);\n  }\n}\n```\n\n## Modern TypeScript Configuration\n\n### Strict TypeScript Setup\n```json\n\u002F\u002F tsconfig.json\n{\n  \"compilerOptions\": {\n    \"target\": \"ES2022\",\n    \"lib\": [\"ES2022\"],\n    \"module\": \"NodeNext\",\n    \"moduleResolution\": \"NodeNext\",\n    \"declaration\": true,\n    \"outDir\": \".\u002Fdist\",\n    \"strict\": true,\n    \"exactOptionalPropertyTypes\": true,\n    \"noImplicitReturns\": true,\n    \"noFallthroughCasesInSwitch\": true,\n    \"noUncheckedIndexedAccess\": true,\n    \"noImplicitOverride\": true,\n    \"experimentalDecorators\": true,\n    \"emitDecoratorMetadata\": true,\n    \"skipLibCheck\": true,\n    \"forceConsistentCasingInFileNames\": true,\n    \"resolveJsonModule\": true,\n    \"esModuleInterop\": true,\n    \"allowSyntheticDefaultImports\": true,\n    \"baseUrl\": \".\",\n    \"paths\": {\n      \"@\u002F*\": [\"src\u002F*\"],\n      \"@core\u002F*\": [\"src\u002Fcore\u002F*\"],\n      \"@shared\u002F*\": [\"src\u002Fcore\u002Fshared\u002F*\"],\n      \"@domains\u002F*\": [\"src\u002Fcore\u002Fdomains\u002F*\"]\n    }\n  },\n  \"include\": [\"src\u002F**\u002F*\"],\n  \"exclude\": [\"node_modules\", \"dist\", \"**\u002F*.test.ts\", \"**\u002F*.spec.ts\"]\n}\n```\n\n## Testing Implementation\n\n### Domain Unit Tests\n```typescript\n\u002F\u002F src\u002Fcore\u002Fdomains\u002Ftask-management\u002F__tests__\u002Fentities\u002Ftask.entity.test.ts\ndescribe('Task Entity', () => {\n  let task: Task;\n\n  beforeEach(() => {\n    task = Task.create('Test task', Priority.medium());\n  });\n\n  describe('creation', () => {\n    it('should create task with pending status', () => {\n      expect(task.status.isPending()).toBe(true);\n      expect(task.description).toBe('Test task');\n      expect(task.priority.equals(Priority.medium())).toBe(true);\n    });\n\n    it('should generate unique ID', () => {\n      const task1 = Task.create('Task 1', Priority.low());\n      const task2 = Task.create('Task 2', Priority.low());\n\n      expect(task1.id.equals(task2.id)).toBe(false);\n    });\n  });\n\n  describe('assignment', () => {\n    it('should assign to agent and change status', () => {\n      const agentId = 'agent-123';\n\n      task.assignTo(agentId);\n\n      expect(task.assignedAgentId).toBe(agentId);\n      expect(task.status.isAssigned()).toBe(true);\n    });\n\n    it('should emit TaskAssignedEvent when assigned', () => {\n      const agentId = 'agent-123';\n\n      task.assignTo(agentId);\n\n      const events = task.getUncommittedEvents();\n      expect(events).toHaveLength(1);\n      expect(events[0]).toBeInstanceOf(TaskAssignedEvent);\n    });\n\n    it('should not allow assignment of completed task', () => {\n      task.assignTo('agent-123');\n      task.complete(TaskResult.success('done'));\n\n      expect(() => task.assignTo('agent-456'))\n        .toThrow('Cannot assign completed task');\n    });\n  });\n});\n```\n\n### Integration Tests\n```typescript\n\u002F\u002F src\u002Fcore\u002Fdomains\u002Ftask-management\u002F__tests__\u002Fintegration\u002Ftask-repository.integration.test.ts\ndescribe('TaskRepository Integration', () => {\n  let repository: SqliteTaskRepository;\n  let db: Database;\n\n  beforeEach(async () => {\n    db = new Database(':memory:');\n    await setupTasksTable(db);\n    repository = new SqliteTaskRepository(db, new ConsoleLogger());\n  });\n\n  afterEach(async () => {\n    await db.close();\n  });\n\n  it('should save and retrieve task', async () => {\n    const task = Task.create('Test task', Priority.high());\n\n    await repository.save(task);\n    const retrieved = await repository.findById(task.id);\n\n    expect(retrieved).toBeDefined();\n    expect(retrieved!.id.equals(task.id)).toBe(true);\n    expect(retrieved!.description).toBe('Test task');\n    expect(retrieved!.priority.equals(Priority.high())).toBe(true);\n  });\n\n  it('should find pending tasks ordered by priority', async () => {\n    const lowTask = Task.create('Low priority', Priority.low());\n    const highTask = Task.create('High priority', Priority.high());\n\n    await repository.save(lowTask);\n    await repository.save(highTask);\n\n    const pending = await repository.findPendingTasks();\n\n    expect(pending).toHaveLength(2);\n    expect(pending[0].id.equals(highTask.id)).toBe(true); \u002F\u002F High priority first\n    expect(pending[1].id.equals(lowTask.id)).toBe(true);\n  });\n});\n```\n\n## Performance Optimizations\n\n### Entity Caching\n```typescript\n\u002F\u002F src\u002Fcore\u002Fshared\u002Finfrastructure\u002Fentity-cache.ts\n@Injectable()\nexport class EntityCache\u003CT extends Entity\u003Cany>> {\n  private cache = new Map\u003Cstring, { entity: T; timestamp: number }>();\n  private readonly ttl: number = 300000; \u002F\u002F 5 minutes\n\n  set(id: string, entity: T): void {\n    this.cache.set(id, { entity, timestamp: Date.now() });\n  }\n\n  get(id: string): T | null {\n    const cached = this.cache.get(id);\n    if (!cached) return null;\n\n    \u002F\u002F Check TTL\n    if (Date.now() - cached.timestamp > this.ttl) {\n      this.cache.delete(id);\n      return null;\n    }\n\n    return cached.entity;\n  }\n\n  invalidate(id: string): void {\n    this.cache.delete(id);\n  }\n\n  clear(): void {\n    this.cache.clear();\n  }\n}\n```\n\n## Success Metrics\n\n- [ ] **Domain Isolation**: 100% clean dependency boundaries\n- [ ] **Test Coverage**: >90% unit test coverage for domain logic\n- [ ] **Type Safety**: Strict TypeScript compilation with zero any types\n- [ ] **Performance**: \u003C50ms average use case execution time\n- [ ] **Memory Efficiency**: \u003C100MB heap usage for core domains\n- [ ] **Plugin Architecture**: Modular domain loading capability\n\n## Related V3 Skills\n\n- `v3-ddd-architecture` - DDD architectural design\n- `v3-mcp-optimization` - MCP server integration\n- `v3-memory-unification` - AgentDB repository integration\n- `v3-swarm-coordination` - Swarm domain implementation\n\n## Usage Examples\n\n### Complete Core Implementation\n```bash\n# Full core module implementation\nTask(\"Core implementation\",\n     \"Implement all core domains with DDD patterns and comprehensive testing\",\n     \"core-implementer\")\n```\n\n### Domain-Specific Implementation\n```bash\n# Single domain implementation\nTask(\"Task domain implementation\",\n     \"Implement task management domain with entities, services, and repositories\",\n     \"core-implementer\")\n```","# V3 Core Implementation\n\n## What This Skill Does\n\nImplements the core TypeScript modules for claude-flow v3 following Domain-Driven Design principles, clean architecture patterns, and modern TypeScript best practices with comprehensive test coverage.\n\n## Quick Start\n\n```bash\n# Initialize core implementation\nTask(\"Core foundation\", \"Set up DDD domain structure and base classes\", \"core-implementer\")\n\n# Domain implementation (parallel)\nTask(\"Task domain\", \"Implement task management domain with entities and services\", \"core-implementer\")\nTask(\"Session domain\", \"Implement session management domain\", \"core-implementer\")\nTask(\"Health domain\", \"Implement health monitoring domain\", \"core-implementer\")\n```\n\n## Core Implementation Architecture\n\n### Domain Structure\n```\nsrc\u002F\n├── core\u002F\n│   ├── kernel\u002F                     # Microkernel pattern\n│   │   ├── claude-flow-kernel.ts\n│   │   ├── domain-registry.ts\n│   │   └── plugin-loader.ts\n│   │\n│   ├── domains\u002F                    # DDD Bounded Contexts\n│   │   ├── task-management\u002F\n│   │   │   ├── entities\u002F\n│   │   │   ├── value-objects\u002F\n│   │   │   ├── services\u002F\n│   │   │   ├── repositories\u002F\n│   │   │   └── events\u002F\n│   │   │\n│   │   ├── session-management\u002F\n│   │   ├── health-monitoring\u002F\n│   │   ├── lifecycle-management\u002F\n│   │   └── event-coordination\u002F\n│   │\n│   ├── shared\u002F                     # Shared kernel\n│   │   ├── domain\u002F\n│   │   │   ├── entity.ts\n│   │   │   ├── value-object.ts\n│   │   │   ├── domain-event.ts\n│   │   │   └── aggregate-root.ts\n│   │   │\n│   │   ├── infrastructure\u002F\n│   │   │   ├── event-bus.ts\n│   │   │   ├── dependency-container.ts\n│   │   │   └── logger.ts\n│   │   │\n│   │   └── types\u002F\n│   │       ├── common.ts\n│   │       ├── errors.ts\n│   │       └── interfaces.ts\n│   │\n│   └── application\u002F                # Application services\n│       ├── use-cases\u002F\n│       ├── commands\u002F\n│       ├── queries\u002F\n│       └── handlers\u002F\n```\n\n## Base Domain Classes\n\n### Entity Base Class\n```typescript\n\u002F\u002F src\u002Fcore\u002Fshared\u002Fdomain\u002Fentity.ts\nexport abstract class Entity\u003CT> {\n  protected readonly _id: T;\n  private _domainEvents: DomainEvent[] = [];\n\n  constructor(id: T) {\n    this._id = id;\n  }\n\n  get id(): T {\n    return this._id;\n  }\n\n  public equals(object?: Entity\u003CT>): boolean {\n    if (object == null || object == undefined) {\n      return false;\n    }\n\n    if (this === object) {\n      return true;\n    }\n\n    if (!(object instanceof Entity)) {\n      return false;\n    }\n\n    return this._id === object._id;\n  }\n\n  protected addDomainEvent(domainEvent: DomainEvent): void {\n    this._domainEvents.push(domainEvent);\n  }\n\n  public getUncommittedEvents(): DomainEvent[] {\n    return this._domainEvents;\n  }\n\n  public markEventsAsCommitted(): void {\n    this._domainEvents = [];\n  }\n}\n```\n\n### Value Object Base Class\n```typescript\n\u002F\u002F src\u002Fcore\u002Fshared\u002Fdomain\u002Fvalue-object.ts\nexport abstract class ValueObject\u003CT> {\n  protected readonly props: T;\n\n  constructor(props: T) {\n    this.props = Object.freeze(props);\n  }\n\n  public equals(object?: ValueObject\u003CT>): boolean {\n    if (object == null || object == undefined) {\n      return false;\n    }\n\n    if (this === object) {\n      return true;\n    }\n\n    return JSON.stringify(this.props) === JSON.stringify(object.props);\n  }\n\n  get value(): T {\n    return this.props;\n  }\n}\n```\n\n### Aggregate Root\n```typescript\n\u002F\u002F src\u002Fcore\u002Fshared\u002Fdomain\u002Faggregate-root.ts\nexport abstract class AggregateRoot\u003CT> extends Entity\u003CT> {\n  private _version: number = 0;\n\n  get version(): number {\n    return this._version;\n  }\n\n  protected incrementVersion(): void {\n    this._version++;\n  }\n\n  public applyEvent(event: DomainEvent): void {\n    this.addDomainEvent(event);\n    this.incrementVersion();\n  }\n}\n```\n\n## Task Management Domain Implementation\n\n### Task Entity\n```typescript\n\u002F\u002F src\u002Fcore\u002Fdomains\u002Ftask-management\u002Fentities\u002Ftask.entity.ts\nimport { AggregateRoot } from '..\u002F..\u002F..\u002Fshared\u002Fdomain\u002Faggregate-root';\nimport { TaskId } from '..\u002Fvalue-objects\u002Ftask-id.vo';\nimport { TaskStatus } from '..\u002Fvalue-objects\u002Ftask-status.vo';\nimport { Priority } from '..\u002Fvalue-objects\u002Fpriority.vo';\nimport { TaskAssignedEvent } from '..\u002Fevents\u002Ftask-assigned.event';\n\ninterface TaskProps {\n  id: TaskId;\n  description: string;\n  priority: Priority;\n  status: TaskStatus;\n  assignedAgentId?: string;\n  createdAt: Date;\n  updatedAt: Date;\n}\n\nexport class Task extends AggregateRoot\u003CTaskId> {\n  private props: TaskProps;\n\n  private constructor(props: TaskProps) {\n    super(props.id);\n    this.props = props;\n  }\n\n  static create(description: string, priority: Priority): Task {\n    const task = new Task({\n      id: TaskId.create(),\n      description,\n      priority,\n      status: TaskStatus.pending(),\n      createdAt: new Date(),\n      updatedAt: new Date()\n    });\n\n    return task;\n  }\n\n  static reconstitute(props: TaskProps): Task {\n    return new Task(props);\n  }\n\n  public assignTo(agentId: string): void {\n    if (this.props.status.equals(TaskStatus.completed())) {\n      throw new Error('Cannot assign completed task');\n    }\n\n    this.props.assignedAgentId = agentId;\n    this.props.status = TaskStatus.assigned();\n    this.props.updatedAt = new Date();\n\n    this.applyEvent(new TaskAssignedEvent(\n      this.id.value,\n      agentId,\n      this.props.priority\n    ));\n  }\n\n  public complete(result: TaskResult): void {\n    if (!this.props.assignedAgentId) {\n      throw new Error('Cannot complete unassigned task');\n    }\n\n    this.props.status = TaskStatus.completed();\n    this.props.updatedAt = new Date();\n\n    this.applyEvent(new TaskCompletedEvent(\n      this.id.value,\n      result,\n      this.calculateDuration()\n    ));\n  }\n\n  \u002F\u002F Getters\n  get description(): string { return this.props.description; }\n  get priority(): Priority { return this.props.priority; }\n  get status(): TaskStatus { return this.props.status; }\n  get assignedAgentId(): string | undefined { return this.props.assignedAgentId; }\n  get createdAt(): Date { return this.props.createdAt; }\n  get updatedAt(): Date { return this.props.updatedAt; }\n\n  private calculateDuration(): number {\n    return this.props.updatedAt.getTime() - this.props.createdAt.getTime();\n  }\n}\n```\n\n### Task Value Objects\n```typescript\n\u002F\u002F src\u002Fcore\u002Fdomains\u002Ftask-management\u002Fvalue-objects\u002Ftask-id.vo.ts\nexport class TaskId extends ValueObject\u003Cstring> {\n  private constructor(value: string) {\n    super({ value });\n  }\n\n  static create(): TaskId {\n    return new TaskId(crypto.randomUUID());\n  }\n\n  static fromString(id: string): TaskId {\n    if (!id || id.length === 0) {\n      throw new Error('TaskId cannot be empty');\n    }\n    return new TaskId(id);\n  }\n\n  get value(): string {\n    return this.props.value;\n  }\n}\n\n\u002F\u002F src\u002Fcore\u002Fdomains\u002Ftask-management\u002Fvalue-objects\u002Ftask-status.vo.ts\ntype TaskStatusType = 'pending' | 'assigned' | 'in_progress' | 'completed' | 'failed';\n\nexport class TaskStatus extends ValueObject\u003CTaskStatusType> {\n  private constructor(status: TaskStatusType) {\n    super({ value: status });\n  }\n\n  static pending(): TaskStatus { return new TaskStatus('pending'); }\n  static assigned(): TaskStatus { return new TaskStatus('assigned'); }\n  static inProgress(): TaskStatus { return new TaskStatus('in_progress'); }\n  static completed(): TaskStatus { return new TaskStatus('completed'); }\n  static failed(): TaskStatus { return new TaskStatus('failed'); }\n\n  get value(): TaskStatusType {\n    return this.props.value;\n  }\n\n  public isPending(): boolean { return this.value === 'pending'; }\n  public isAssigned(): boolean { return this.value === 'assigned'; }\n  public isInProgress(): boolean { return this.value === 'in_progress'; }\n  public isCompleted(): boolean { return this.value === 'completed'; }\n  public isFailed(): boolean { return this.value === 'failed'; }\n}\n\n\u002F\u002F src\u002Fcore\u002Fdomains\u002Ftask-management\u002Fvalue-objects\u002Fpriority.vo.ts\ntype PriorityLevel = 'low' | 'medium' | 'high' | 'critical';\n\nexport class Priority extends ValueObject\u003CPriorityLevel> {\n  private constructor(level: PriorityLevel) {\n    super({ value: level });\n  }\n\n  static low(): Priority { return new Priority('low'); }\n  static medium(): Priority { return new Priority('medium'); }\n  static high(): Priority { return new Priority('high'); }\n  static critical(): Priority { return new Priority('critical'); }\n\n  get value(): PriorityLevel {\n    return this.props.value;\n  }\n\n  public getNumericValue(): number {\n    const priorities = { low: 1, medium: 2, high: 3, critical: 4 };\n    return priorities[this.value];\n  }\n}\n```\n\n## Domain Services\n\n### Task Scheduling Service\n```typescript\n\u002F\u002F src\u002Fcore\u002Fdomains\u002Ftask-management\u002Fservices\u002Ftask-scheduling.service.ts\nimport { Injectable } from '..\u002F..\u002F..\u002Fshared\u002Finfrastructure\u002Fdependency-container';\nimport { Task } from '..\u002Fentities\u002Ftask.entity';\nimport { Priority } from '..\u002Fvalue-objects\u002Fpriority.vo';\n\n@Injectable()\nexport class TaskSchedulingService {\n  public prioritizeTasks(tasks: Task[]): Task[] {\n    return tasks.sort((a, b) =>\n      b.priority.getNumericValue() - a.priority.getNumericValue()\n    );\n  }\n\n  public canSchedule(task: Task, agentCapacity: number): boolean {\n    if (agentCapacity \u003C= 0) return false;\n\n    \u002F\u002F Critical tasks always schedulable\n    if (task.priority.equals(Priority.critical())) return true;\n\n    \u002F\u002F Other logic based on capacity\n    return true;\n  }\n\n  public calculateEstimatedDuration(task: Task): number {\n    \u002F\u002F Simple heuristic - would use ML in real implementation\n    const baseTime = 300000; \u002F\u002F 5 minutes\n    const priorityMultiplier = {\n      low: 0.5,\n      medium: 1.0,\n      high: 1.5,\n      critical: 2.0\n    };\n\n    return baseTime * priorityMultiplier[task.priority.value];\n  }\n}\n```\n\n## Repository Interfaces & Implementations\n\n### Task Repository Interface\n```typescript\n\u002F\u002F src\u002Fcore\u002Fdomains\u002Ftask-management\u002Frepositories\u002Ftask.repository.ts\nexport interface ITaskRepository {\n  save(task: Task): Promise\u003Cvoid>;\n  findById(id: TaskId): Promise\u003CTask | null>;\n  findByAgentId(agentId: string): Promise\u003CTask[]>;\n  findByStatus(status: TaskStatus): Promise\u003CTask[]>;\n  findPendingTasks(): Promise\u003CTask[]>;\n  delete(id: TaskId): Promise\u003Cvoid>;\n}\n```\n\n### SQLite Implementation\n```typescript\n\u002F\u002F src\u002Fcore\u002Fdomains\u002Ftask-management\u002Frepositories\u002Fsqlite-task.repository.ts\n@Injectable()\nexport class SqliteTaskRepository implements ITaskRepository {\n  constructor(\n    @Inject('Database') private db: Database,\n    @Inject('Logger') private logger: ILogger\n  ) {}\n\n  async save(task: Task): Promise\u003Cvoid> {\n    const sql = `\n      INSERT OR REPLACE INTO tasks (\n        id, description, priority, status, assigned_agent_id, created_at, updated_at\n      ) VALUES (?, ?, ?, ?, ?, ?, ?)\n    `;\n\n    await this.db.run(sql, [\n      task.id.value,\n      task.description,\n      task.priority.value,\n      task.status.value,\n      task.assignedAgentId,\n      task.createdAt.toISOString(),\n      task.updatedAt.toISOString()\n    ]);\n\n    this.logger.debug(`Task saved: ${task.id.value}`);\n  }\n\n  async findById(id: TaskId): Promise\u003CTask | null> {\n    const sql = 'SELECT * FROM tasks WHERE id = ?';\n    const row = await this.db.get(sql, [id.value]);\n\n    return row ? this.mapRowToTask(row) : null;\n  }\n\n  async findPendingTasks(): Promise\u003CTask[]> {\n    const sql = 'SELECT * FROM tasks WHERE status = ? ORDER BY priority DESC, created_at ASC';\n    const rows = await this.db.all(sql, ['pending']);\n\n    return rows.map(row => this.mapRowToTask(row));\n  }\n\n  private mapRowToTask(row: any): Task {\n    return Task.reconstitute({\n      id: TaskId.fromString(row.id),\n      description: row.description,\n      priority: Priority.fromString(row.priority),\n      status: TaskStatus.fromString(row.status),\n      assignedAgentId: row.assigned_agent_id,\n      createdAt: new Date(row.created_at),\n      updatedAt: new Date(row.updated_at)\n    });\n  }\n}\n```\n\n## Application Layer\n\n### Use Case Implementation\n```typescript\n\u002F\u002F src\u002Fcore\u002Fapplication\u002Fuse-cases\u002Fassign-task.use-case.ts\n@Injectable()\nexport class AssignTaskUseCase {\n  constructor(\n    @Inject('TaskRepository') private taskRepository: ITaskRepository,\n    @Inject('AgentRepository') private agentRepository: IAgentRepository,\n    @Inject('DomainEventBus') private eventBus: DomainEventBus,\n    @Inject('Logger') private logger: ILogger\n  ) {}\n\n  async execute(command: AssignTaskCommand): Promise\u003CAssignTaskResult> {\n    try {\n      \u002F\u002F 1. Validate command\n      await this.validateCommand(command);\n\n      \u002F\u002F 2. Load aggregates\n      const task = await this.taskRepository.findById(command.taskId);\n      if (!task) {\n        throw new TaskNotFoundError(command.taskId);\n      }\n\n      const agent = await this.agentRepository.findById(command.agentId);\n      if (!agent) {\n        throw new AgentNotFoundError(command.agentId);\n      }\n\n      \u002F\u002F 3. Business logic\n      if (!agent.canAcceptTask(task)) {\n        throw new AgentCannotAcceptTaskError(command.agentId, command.taskId);\n      }\n\n      task.assignTo(command.agentId);\n      agent.acceptTask(task.id);\n\n      \u002F\u002F 4. Persist changes\n      await Promise.all([\n        this.taskRepository.save(task),\n        this.agentRepository.save(agent)\n      ]);\n\n      \u002F\u002F 5. Publish domain events\n      const events = [\n        ...task.getUncommittedEvents(),\n        ...agent.getUncommittedEvents()\n      ];\n\n      for (const event of events) {\n        await this.eventBus.publish(event);\n      }\n\n      task.markEventsAsCommitted();\n      agent.markEventsAsCommitted();\n\n      \u002F\u002F 6. Return result\n      this.logger.info(`Task ${command.taskId.value} assigned to agent ${command.agentId}`);\n\n      return AssignTaskResult.success({\n        taskId: task.id,\n        agentId: command.agentId,\n        assignedAt: new Date()\n      });\n\n    } catch (error) {\n      this.logger.error(`Failed to assign task ${command.taskId.value}:`, error);\n      return AssignTaskResult.failure(error);\n    }\n  }\n\n  private async validateCommand(command: AssignTaskCommand): Promise\u003Cvoid> {\n    if (!command.taskId) {\n      throw new ValidationError('Task ID is required');\n    }\n    if (!command.agentId) {\n      throw new ValidationError('Agent ID is required');\n    }\n  }\n}\n```\n\n## Dependency Injection Setup\n\n### Container Configuration\n```typescript\n\u002F\u002F src\u002Fcore\u002Fshared\u002Finfrastructure\u002Fdependency-container.ts\nimport { Container } from 'inversify';\nimport { TYPES } from '.\u002Ftypes';\n\nexport class DependencyContainer {\n  private container: Container;\n\n  constructor() {\n    this.container = new Container();\n    this.setupBindings();\n  }\n\n  private setupBindings(): void {\n    \u002F\u002F Repositories\n    this.container.bind\u003CITaskRepository>(TYPES.TaskRepository)\n      .to(SqliteTaskRepository)\n      .inSingletonScope();\n\n    this.container.bind\u003CIAgentRepository>(TYPES.AgentRepository)\n      .to(SqliteAgentRepository)\n      .inSingletonScope();\n\n    \u002F\u002F Services\n    this.container.bind\u003CTaskSchedulingService>(TYPES.TaskSchedulingService)\n      .to(TaskSchedulingService)\n      .inSingletonScope();\n\n    \u002F\u002F Use Cases\n    this.container.bind\u003CAssignTaskUseCase>(TYPES.AssignTaskUseCase)\n      .to(AssignTaskUseCase)\n      .inSingletonScope();\n\n    \u002F\u002F Infrastructure\n    this.container.bind\u003CILogger>(TYPES.Logger)\n      .to(ConsoleLogger)\n      .inSingletonScope();\n\n    this.container.bind\u003CDomainEventBus>(TYPES.DomainEventBus)\n      .to(InMemoryDomainEventBus)\n      .inSingletonScope();\n  }\n\n  get\u003CT>(serviceIdentifier: symbol): T {\n    return this.container.get\u003CT>(serviceIdentifier);\n  }\n\n  bind\u003CT>(serviceIdentifier: symbol): BindingToSyntax\u003CT> {\n    return this.container.bind\u003CT>(serviceIdentifier);\n  }\n}\n```\n\n## Modern TypeScript Configuration\n\n### Strict TypeScript Setup\n```json\n\u002F\u002F tsconfig.json\n{\n  \"compilerOptions\": {\n    \"target\": \"ES2022\",\n    \"lib\": [\"ES2022\"],\n    \"module\": \"NodeNext\",\n    \"moduleResolution\": \"NodeNext\",\n    \"declaration\": true,\n    \"outDir\": \".\u002Fdist\",\n    \"strict\": true,\n    \"exactOptionalPropertyTypes\": true,\n    \"noImplicitReturns\": true,\n    \"noFallthroughCasesInSwitch\": true,\n    \"noUncheckedIndexedAccess\": true,\n    \"noImplicitOverride\": true,\n    \"experimentalDecorators\": true,\n    \"emitDecoratorMetadata\": true,\n    \"skipLibCheck\": true,\n    \"forceConsistentCasingInFileNames\": true,\n    \"resolveJsonModule\": true,\n    \"esModuleInterop\": true,\n    \"allowSyntheticDefaultImports\": true,\n    \"baseUrl\": \".\",\n    \"paths\": {\n      \"@\u002F*\": [\"src\u002F*\"],\n      \"@core\u002F*\": [\"src\u002Fcore\u002F*\"],\n      \"@shared\u002F*\": [\"src\u002Fcore\u002Fshared\u002F*\"],\n      \"@domains\u002F*\": [\"src\u002Fcore\u002Fdomains\u002F*\"]\n    }\n  },\n  \"include\": [\"src\u002F**\u002F*\"],\n  \"exclude\": [\"node_modules\", \"dist\", \"**\u002F*.test.ts\", \"**\u002F*.spec.ts\"]\n}\n```\n\n## Testing Implementation\n\n### Domain Unit Tests\n```typescript\n\u002F\u002F src\u002Fcore\u002Fdomains\u002Ftask-management\u002F__tests__\u002Fentities\u002Ftask.entity.test.ts\ndescribe('Task Entity', () => {\n  let task: Task;\n\n  beforeEach(() => {\n    task = Task.create('Test task', Priority.medium());\n  });\n\n  describe('creation', () => {\n    it('should create task with pending status', () => {\n      expect(task.status.isPending()).toBe(true);\n      expect(task.description).toBe('Test task');\n      expect(task.priority.equals(Priority.medium())).toBe(true);\n    });\n\n    it('should generate unique ID', () => {\n      const task1 = Task.create('Task 1', Priority.low());\n      const task2 = Task.create('Task 2', Priority.low());\n\n      expect(task1.id.equals(task2.id)).toBe(false);\n    });\n  });\n\n  describe('assignment', () => {\n    it('should assign to agent and change status', () => {\n      const agentId = 'agent-123';\n\n      task.assignTo(agentId);\n\n      expect(task.assignedAgentId).toBe(agentId);\n      expect(task.status.isAssigned()).toBe(true);\n    });\n\n    it('should emit TaskAssignedEvent when assigned', () => {\n      const agentId = 'agent-123';\n\n      task.assignTo(agentId);\n\n      const events = task.getUncommittedEvents();\n      expect(events).toHaveLength(1);\n      expect(events[0]).toBeInstanceOf(TaskAssignedEvent);\n    });\n\n    it('should not allow assignment of completed task', () => {\n      task.assignTo('agent-123');\n      task.complete(TaskResult.success('done'));\n\n      expect(() => task.assignTo('agent-456'))\n        .toThrow('Cannot assign completed task');\n    });\n  });\n});\n```\n\n### Integration Tests\n```typescript\n\u002F\u002F src\u002Fcore\u002Fdomains\u002Ftask-management\u002F__tests__\u002Fintegration\u002Ftask-repository.integration.test.ts\ndescribe('TaskRepository Integration', () => {\n  let repository: SqliteTaskRepository;\n  let db: Database;\n\n  beforeEach(async () => {\n    db = new Database(':memory:');\n    await setupTasksTable(db);\n    repository = new SqliteTaskRepository(db, new ConsoleLogger());\n  });\n\n  afterEach(async () => {\n    await db.close();\n  });\n\n  it('should save and retrieve task', async () => {\n    const task = Task.create('Test task', Priority.high());\n\n    await repository.save(task);\n    const retrieved = await repository.findById(task.id);\n\n    expect(retrieved).toBeDefined();\n    expect(retrieved!.id.equals(task.id)).toBe(true);\n    expect(retrieved!.description).toBe('Test task');\n    expect(retrieved!.priority.equals(Priority.high())).toBe(true);\n  });\n\n  it('should find pending tasks ordered by priority', async () => {\n    const lowTask = Task.create('Low priority', Priority.low());\n    const highTask = Task.create('High priority', Priority.high());\n\n    await repository.save(lowTask);\n    await repository.save(highTask);\n\n    const pending = await repository.findPendingTasks();\n\n    expect(pending).toHaveLength(2);\n    expect(pending[0].id.equals(highTask.id)).toBe(true); \u002F\u002F High priority first\n    expect(pending[1].id.equals(lowTask.id)).toBe(true);\n  });\n});\n```\n\n## Performance Optimizations\n\n### Entity Caching\n```typescript\n\u002F\u002F src\u002Fcore\u002Fshared\u002Finfrastructure\u002Fentity-cache.ts\n@Injectable()\nexport class EntityCache\u003CT extends Entity\u003Cany>> {\n  private cache = new Map\u003Cstring, { entity: T; timestamp: number }>();\n  private readonly ttl: number = 300000; \u002F\u002F 5 minutes\n\n  set(id: string, entity: T): void {\n    this.cache.set(id, { entity, timestamp: Date.now() });\n  }\n\n  get(id: string): T | null {\n    const cached = this.cache.get(id);\n    if (!cached) return null;\n\n    \u002F\u002F Check TTL\n    if (Date.now() - cached.timestamp > this.ttl) {\n      this.cache.delete(id);\n      return null;\n    }\n\n    return cached.entity;\n  }\n\n  invalidate(id: string): void {\n    this.cache.delete(id);\n  }\n\n  clear(): void {\n    this.cache.clear();\n  }\n}\n```\n\n## Success Metrics\n\n- [ ] **Domain Isolation**: 100% clean dependency boundaries\n- [ ] **Test Coverage**: >90% unit test coverage for domain logic\n- [ ] **Type Safety**: Strict TypeScript compilation with zero any types\n- [ ] **Performance**: \u003C50ms average use case execution time\n- [ ] **Memory Efficiency**: \u003C100MB heap usage for core domains\n- [ ] **Plugin Architecture**: Modular domain loading capability\n\n## Related V3 Skills\n\n- `v3-ddd-architecture` - DDD architectural design\n- `v3-mcp-optimization` - MCP server integration\n- `v3-memory-unification` - AgentDB repository integration\n- `v3-swarm-coordination` - Swarm domain implementation\n\n## Usage Examples\n\n### Complete Core Implementation\n```bash\n# Full core module implementation\nTask(\"Core implementation\",\n     \"Implement all core domains with DDD patterns and comprehensive testing\",\n     \"core-implementer\")\n```\n\n### Domain-Specific Implementation\n```bash\n# Single domain implementation\nTask(\"Task domain implementation\",\n     \"Implement task management domain with entities, services, and repositories\",\n     \"core-implementer\")\n```",{"name":5,"description":7},"main","63caf799a0409377ce4fd434e24e9eac7c05c6fa",".claude\u002Fskills\u002Fv3-core-implementation",0,"https:\u002F\u002Fgithub.com\u002Fmanykarim\u002Frobotframework-agentguard","https:\u002F\u002Fgithub.com\u002Fmanykarim","2026-07-27 14:20:37",{"source":8,"skillName":5,"commands":56,"prompt":66,"zipAvailable":67},[57,60,63],{"tool":58,"command":59},"npx","npx skills add manykarim\u002Frobotframework-agentguard --skill \"V3 Core Implementation\"",{"tool":61,"command":62},"bunx","bunx skills add manykarim\u002Frobotframework-agentguard --skill \"V3 Core Implementation\"",{"tool":64,"command":65},"pnpm","pnpm dlx skills add manykarim\u002Frobotframework-agentguard --skill \"V3 Core Implementation\"","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmanykarim\u002Frobotframework-agentguard\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fv3-core-implementation\u002FSKILL.md",true,[],[70,90,98,115,129,144],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":79,"publishedAt":43},"01M71S584X6G22VN1KZ42DZ33K","good-example","Demonstrate a minimal valid Agent Skill used by AgentGuard's own tests.","https:\u002F\u002Fgithub.com\u002Fmanykarim\u002Frobotframework-agentguard\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fskills\u002Fgood-skill\u002FSKILL.md",[76],{"categoryNo":77,"categoryName":78,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[80,81,82,83,84,85,86,87,88,89],"good example","good","example","valid","agentguard","read","write","minimal","tests","agent skill",{"skillNo":91,"name":92,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":43},"01M71S55P2APRSAC0S9F5X556A","bad-example","https:\u002F\u002Fgithub.com\u002Fmanykarim\u002Frobotframework-agentguard\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fskills\u002Fbad-skill\u002FSKILL.md",[],[96,82,97,85],"bad","bad example",{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":105,"publishedAt":43},"01M71S53FGWCB5XXX4QGW3RF4P","injection-skill","Demonstrates a prompt-injection payload embedded in the body.","https:\u002F\u002Fgithub.com\u002Fmanykarim\u002Frobotframework-agentguard\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fsecurity\u002Finjection-skill\u002FSKILL.md",[104],{"categoryNo":77,"categoryName":78,"taxonomyType":21,"taxonomyTypeDesc":22},[106,36,85,107,108,109,110,111,112,113,114],"injection skill","payload","body","prompt","unknown","Bash","prompt-injection","author","embedded",{"skillNo":116,"name":117,"nameZh":6,"description":118,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":119,"categories":120,"keywords":122,"publishedAt":43},"01M71S518MA1JN7F1DZ5XVRH06","curl-pipe-skill","Skill whose installer script demonstrates the `curl ... | sh` antipattern.","https:\u002F\u002Fgithub.com\u002Fmanykarim\u002Frobotframework-agentguard\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fsecurity\u002Fcurl-pipe-skill\u002FSKILL.md",[121],{"categoryNo":77,"categoryName":78,"taxonomyType":21,"taxonomyTypeDesc":22},[123,124,125,126,127,110,111,113,128],"curl","pipe","curl pipe skill","installer","antipattern","script",{"skillNo":130,"name":131,"nameZh":6,"description":132,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":133,"categories":134,"keywords":136,"publishedAt":43},"01M71S4YYFE3HJKDEQR5Z944ZW","clean-skill","A minimal, well-formed skill used as the security-scanner happy path.","https:\u002F\u002Fgithub.com\u002Fmanykarim\u002Frobotframework-agentguard\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fsecurity\u002Fclean-skill\u002FSKILL.md",[135],{"categoryNo":77,"categoryName":78,"taxonomyType":21,"taxonomyTypeDesc":22},[137,34,84,138,87,139,140,141,142,85,143],"clean skill","scanner","grep","true","as","security","path",{"skillNo":145,"name":146,"nameZh":6,"description":147,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":148,"categories":149,"keywords":150,"publishedAt":43},"01M71S4W60AZYGA57HJWYBQZMJ","rf-libdoc-search","Search Robot Framework library\u002Fresource\u002Fsuite documentation to find matching keywords for a use case. Use when asked to find keywords, search libdoc, match a use case to keywords, or scan multiple libraries\u002Fresources for relevant keywords.","https:\u002F\u002Fgithub.com\u002Fmanykarim\u002Frobotframework-agentguard\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fintegrations\u002Fskills\u002Frf-libdoc-search\u002FSKILL.md",[],[151,152,153,28,154,155,156,157,158,159,160,161,162,163,164,165,166,167],"search","rf libdoc search","case","resources","relevant","scan","libraries","documentation","robot","when","framework","use","match","library","suite","matching","find"]