Implements 123 tasks across 9 phases (T-001..T-809) totaling 146 source files. Monorepo (P0): - 7-package Bun + Turborepo + TypeScript monorepo - dependency-cruiser enforcing 7 forbidden edges + 5 deep-import rules Contracts (P0): - 16 type files (ids/error/event/runtime/ipc/task/worker-result/tool/artifact/evidence/project/provider/permission/ui/capability/platform) Storage & Events (P1): - DatabaseManager + MigrationRunner (19 tables, 22 indexes, 5 schema_meta seeds) - 16 repositories (Repository<T,I,U> pattern, INV-1 status columns via EventStore.project only) - EventSchemaRegistry (54 durable + 7 ephemeral), EventStore, EventBus, EventIngestor - Project/Session/Artifact/Evidence stores + 8-step Recovery Tools & Permission (P2): - PathClassifier (8 categories), CommandRiskAnalyzer (10 categories), SecretRedactor - PermissionEngine 6-layer evaluation (capability→profile→task_scope→risk→credential→user_prompt) - ToolRegistry with 20+ tools across fs/shell/git/project/artifact/context/permission/doctor - CapabilityManifestValidator + CapabilityRegistry LLM & Context (P3): - ModelConfigLoader, CapabilityMatrix, AnthropicCanonicalConverter - AnthropicAdapter + OpenAICompatibleAdapter - ProviderManager facade - PromptLayerLoader (L0/L1/L3/L5), CompactionPolicy, ContextAssembler Worker IPC & Scheduler (P4): - WorkerProtocol (NDJSON), WorkerProcess (exit codes 0-5), WorkerManager (spawn/handshake) - WorkerRuntime (INV-3: IPC only, no direct fs/shell/SQLite) - 5 worker roles (Executor/Reviewer/Debugger/Compactor/ExperienceMiner) - TaskGraph, WavePlanner, RetryPlanner, AgentMonitor, WorkspaceManager - Scheduler (state machine), 8-step Recovery C++ Toolchain (P5): - DiagnosticParser, CppProjectDetector, CMakeConfigurator, CppBuilder - CppTestRunner, CppcheckRunner, ClangdClient - CppToolRegistrar + capability manifest Projection & TUI (P6): - ProjectionStore (hydrate/apply/snapshot/subscribe) - TuiApp + 8 components (Session/Task/Agent/Tool/Diff/Evidence/Permission/Blocker/Hud) - ProjectionClient in-process ref Agents & Knowledge (P7): - MainAgent, ArchitectureDesigner - DebugKnowledgeStore + LearnedMemoryStore (single-writer, outbox model) - Role integration wiring CLI & Doctor & Release (P8): - Logger + DeveloperLogEncryptor (AES-256-GCM) - DoctorService (self_bootstrap first) - RuntimeApp + ServiceRegistry - 11 CLI commands: run/init/doctor/provider/resume/compact/history/session/restore/e2e/release - CliEntrypoint + air<TODO> Audit (in AirPlan/docs/): - Deepseek开发阶段审计.md (97 findings) - Opus开发阶段审计.md (140+ findings, 18 P0 blockers) - MiniMaxM3开发阶段审计.md (18 P0 blockers, focuses on executability) - AirPlan/TODO.md (technical debt + 42 TODOs by phase) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
158 lines
3.8 KiB
TypeScript
Executable File
158 lines
3.8 KiB
TypeScript
Executable File
/**
|
|
* AirCoding Artifact Contracts
|
|
*
|
|
* Implements ArtifactRef, ArtifactCreateInput, ArtifactContext, ArtifactReadResult,
|
|
* ArtifactStore, DebugKnowledgeStore, LearnedMemoryStore, DebugRecord, LearnedMemory
|
|
* per interface-contracts-v1.md §14, §20 and system-detailed-design.md §3.
|
|
*/
|
|
|
|
// Re-export IDs and types needed for these contracts
|
|
import type {
|
|
ArtifactID,
|
|
UUID,
|
|
ISOTimeString,
|
|
JsonObject,
|
|
SessionID,
|
|
TaskID,
|
|
AgentID,
|
|
ToolRunID,
|
|
CommandRunID,
|
|
} from './ids.js'
|
|
export type {
|
|
ArtifactID,
|
|
UUID,
|
|
ISOTimeString,
|
|
JsonObject,
|
|
SessionID,
|
|
TaskID,
|
|
AgentID,
|
|
ToolRunID,
|
|
CommandRunID,
|
|
}
|
|
|
|
// Re-export EntityRef for DebugKnowledgeStore and LearnedMemoryStore
|
|
import type { EntityRef } from './event.js'
|
|
export type { EntityRef }
|
|
|
|
// Re-export EvidenceRef for DebugRecord
|
|
import type { EvidenceRef } from './evidence.js'
|
|
|
|
/**
|
|
* Reference to a stored artifact.
|
|
*/
|
|
export interface ArtifactRef {
|
|
artifact_id: ArtifactID
|
|
uri: string
|
|
path: string
|
|
type: string
|
|
sha256?: string
|
|
size_bytes?: number
|
|
}
|
|
|
|
/**
|
|
* Input for creating a new artifact.
|
|
*/
|
|
export interface ArtifactCreateInput {
|
|
type: string
|
|
original_name?: string
|
|
content?: string
|
|
source_path?: string
|
|
associated_entity_type?: string
|
|
associated_entity_id?: string
|
|
metadata?: JsonObject
|
|
}
|
|
|
|
/**
|
|
* Context information for artifact operations.
|
|
*/
|
|
export interface ArtifactContext {
|
|
session_id: SessionID
|
|
task_id?: TaskID
|
|
agent_id?: AgentID
|
|
tool_run_id?: ToolRunID
|
|
command_run_id?: CommandRunID
|
|
}
|
|
|
|
/**
|
|
* Result of reading an artifact, including optional content.
|
|
*/
|
|
export interface ArtifactReadResult {
|
|
artifact: ArtifactRef
|
|
content?: string | Uint8Array
|
|
content_type?: string
|
|
}
|
|
|
|
/**
|
|
* Storage interface for artifacts.
|
|
*/
|
|
export interface ArtifactStore {
|
|
create(input: ArtifactCreateInput, context: ArtifactContext): Promise<ArtifactRef>
|
|
get(artifact_id: ArtifactID): Promise<ArtifactRef | undefined>
|
|
read(artifact_id: ArtifactID): Promise<ArtifactReadResult>
|
|
}
|
|
|
|
// =============================================================================
|
|
// Knowledge Store Contracts (merged from knowledge.ts per DD §3)
|
|
// =============================================================================
|
|
|
|
/**
|
|
* A debug record capturing failure diagnosis and resolution.
|
|
*/
|
|
export interface DebugRecord {
|
|
debug_record_id: UUID
|
|
task_id?: TaskID
|
|
failure_signature: string
|
|
summary: string
|
|
root_cause?: string
|
|
fix_ref?: string
|
|
evidence_refs?: EvidenceRef[]
|
|
verification_refs?: EvidenceRef[]
|
|
created_at: ISOTimeString
|
|
updated_at: ISOTimeString
|
|
metadata_json?: JsonObject
|
|
}
|
|
|
|
/**
|
|
* Storage interface for debug knowledge records.
|
|
*/
|
|
export interface DebugKnowledgeStore {
|
|
insert(record: DebugRecord): Promise<void>
|
|
lookup_by_signature(failure_signature: string): Promise<DebugRecord[]>
|
|
lookup_by_task(task_id: TaskID): Promise<DebugRecord[]>
|
|
update(debug_record_id: UUID, patch: Partial<DebugRecord>): Promise<void>
|
|
}
|
|
|
|
/**
|
|
* Types of learned memory.
|
|
*/
|
|
export type LearnedMemoryType = 'project_rule' | 'toolchain_rule' | 'skill_update' | 'debug_experience'
|
|
|
|
/**
|
|
* Status of learned memory.
|
|
*/
|
|
export type LearnedMemoryStatus = 'candidate' | 'promoted' | 'archived' | 'rejected'
|
|
|
|
/**
|
|
* A learned memory entry capturing project knowledge.
|
|
*/
|
|
export interface LearnedMemory {
|
|
memory_id: UUID
|
|
memory_type: LearnedMemoryType
|
|
summary: string
|
|
content?: string
|
|
source_ref?: EntityRef
|
|
status: LearnedMemoryStatus
|
|
created_at: ISOTimeString
|
|
updated_at: ISOTimeString
|
|
metadata_json?: JsonObject
|
|
}
|
|
|
|
/**
|
|
* Storage interface for learned memory.
|
|
*/
|
|
export interface LearnedMemoryStore {
|
|
insert(memory: LearnedMemory): Promise<void>
|
|
lookup_by_type(memory_type: LearnedMemoryType): Promise<LearnedMemory[]>
|
|
update_status(memory_id: UUID, status: LearnedMemoryStatus): Promise<void>
|
|
scan_stale(): Promise<LearnedMemory[]>
|
|
} |