P0-P8: Full V1.0.0 Alpha implementation + audit reports
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>
This commit is contained in:
224
packages/contracts/src/platform.ts
Executable file
224
packages/contracts/src/platform.ts
Executable file
@@ -0,0 +1,224 @@
|
||||
// contracts §19 + cross-platform matrix — Platform Contracts
|
||||
// File: platform.ts — DoctorService, DoctorRunInput/Output, DoctorIssue, cross-platform tier enums
|
||||
// Implements: interface-contracts-v1.md §19, cross-platform-matrix-v1.md
|
||||
// Merged: doctor.ts symbols per DD §3
|
||||
|
||||
import type { CapabilityID, ArtifactID } from "./ids.js"
|
||||
|
||||
// =============================================================================
|
||||
// contracts §19 — Doctor Contracts
|
||||
// =============================================================================
|
||||
|
||||
/**
|
||||
* Doctor run mode determines what actions the doctor service can perform.
|
||||
*/
|
||||
export type DoctorRunMode = "read_only" | "fix"
|
||||
|
||||
/**
|
||||
* Doctor run scope determines which capabilities/subsystems to check.
|
||||
*/
|
||||
export type DoctorRunScope = "startup" | "project" | "toolchain" | "release_gate"
|
||||
|
||||
export interface DoctorRunInput {
|
||||
mode: DoctorRunMode
|
||||
scope?: DoctorRunScope
|
||||
capabilities?: CapabilityID[]
|
||||
bundle?: boolean
|
||||
}
|
||||
|
||||
export interface DoctorRunOutput {
|
||||
run_id: string
|
||||
status: "passed" | "issues_found" | "fixed" | "failed"
|
||||
issue_count: number
|
||||
blocking_issue_count: number
|
||||
report_artifact_id?: ArtifactID
|
||||
bundle_artifact_id?: ArtifactID
|
||||
}
|
||||
|
||||
/**
|
||||
* Severity level for doctor issues.
|
||||
*/
|
||||
export type DoctorIssueSeverity = "blocking" | "warning" | "info"
|
||||
|
||||
/**
|
||||
* Category for doctor issues, mapping to different subsystems.
|
||||
*/
|
||||
export type DoctorIssueCategory =
|
||||
| "runtime" // Bun runtime, SQLite, basic shell
|
||||
| "project" // Project initialization, .air directory
|
||||
| "toolchain" // C++ toolchain (CMake, Ninja, gcc/clang, etc.)
|
||||
| "permission" // Permission engine, path policy
|
||||
| "provider" // LLM provider configuration
|
||||
| "workspace" // Workspace management, git worktree
|
||||
| "capability" // Capability registry, tool registration
|
||||
|
||||
/**
|
||||
* A single issue discovered by the doctor service.
|
||||
*/
|
||||
export interface DoctorIssue {
|
||||
id: string
|
||||
severity: DoctorIssueSeverity
|
||||
category: DoctorIssueCategory
|
||||
title: string
|
||||
description: string
|
||||
fix_suggestion?: string
|
||||
evidence_refs?: string[]
|
||||
}
|
||||
|
||||
/**
|
||||
* DoctorService interface for running diagnostic checks.
|
||||
*/
|
||||
export interface DoctorService {
|
||||
run(input: DoctorRunInput): Promise<DoctorRunOutput>
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// contracts §19 — Logging Contracts
|
||||
// =============================================================================
|
||||
|
||||
export interface Logger {
|
||||
debug(message: string, data?: unknown): void
|
||||
info(message: string, data?: unknown): void
|
||||
warn(message: string, data?: unknown): void
|
||||
error(message: string, data?: unknown): void
|
||||
}
|
||||
|
||||
export interface DeveloperLogEncryptor {
|
||||
encrypt_log_chunk(chunk: Uint8Array): Promise<Uint8Array>
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// cross-platform-matrix-v1.md — Platform Tier Enums
|
||||
// =============================================================================
|
||||
|
||||
/**
|
||||
* Platform support levels from cross-platform-matrix-v1.md §1.
|
||||
*/
|
||||
export type PlatformSupportLevel =
|
||||
| "tier_1" // Release-blocking support; tested before release
|
||||
| "tier_2" // Intended support; best-effort validation
|
||||
| "experimental" // May work; no compatibility promise
|
||||
| "unsupported" // Explicit non-target
|
||||
|
||||
/**
|
||||
* Operating system type for platform detection.
|
||||
*/
|
||||
export type PlatformOS = "linux" | "darwin" | "windows" | "unknown"
|
||||
|
||||
/**
|
||||
* CPU architecture type for platform detection.
|
||||
*/
|
||||
export type PlatformArch = "x64" | "arm64" | "arm" | "unknown"
|
||||
|
||||
/**
|
||||
* Libc type for platform detection.
|
||||
*/
|
||||
export type PlatformLibc = "glibc" | "musl" | "unknown"
|
||||
|
||||
/**
|
||||
* Display backend types for GUI evidence collection.
|
||||
*/
|
||||
export interface PlatformDisplayBackend {
|
||||
wayland?: boolean
|
||||
x11?: boolean
|
||||
xvfb?: boolean
|
||||
wslg?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Platform information contract from cross-platform-matrix-v1.md §10.
|
||||
*/
|
||||
export interface PlatformInfo {
|
||||
os: PlatformOS
|
||||
arch: PlatformArch
|
||||
libc?: PlatformLibc
|
||||
shell?: string
|
||||
is_wsl?: boolean
|
||||
display?: PlatformDisplayBackend
|
||||
package_managers?: string[]
|
||||
path_case_sensitive?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Runtime feature support levels for different platforms.
|
||||
*/
|
||||
export type RuntimeFeature =
|
||||
| "bun_runtime"
|
||||
| "cli"
|
||||
| "tui"
|
||||
| "sqlite_session_db"
|
||||
| "ndjson_child_processes"
|
||||
| "tool_registry"
|
||||
| "permission_engine_path_policy"
|
||||
| "doctor_read_only"
|
||||
| "doctor_fix"
|
||||
|
||||
/**
|
||||
* C++ toolchain feature support levels.
|
||||
*/
|
||||
export type ToolchainFeature =
|
||||
| "cmake"
|
||||
| "ninja"
|
||||
| "make_fallback"
|
||||
| "gcc_clang"
|
||||
| "clangd_cli"
|
||||
| "cppcheck"
|
||||
| "ctest_googletest"
|
||||
| "core_dumps_backtrace"
|
||||
|
||||
/**
|
||||
* Filesystem capability support.
|
||||
*/
|
||||
export type FilesystemCapability =
|
||||
| "posix_paths"
|
||||
| "symlink_realpath"
|
||||
| "chmod_exec_bits"
|
||||
| "case_sensitivity"
|
||||
| "project_local_air"
|
||||
| "git_worktree"
|
||||
| "project_outside_backup_repo"
|
||||
|
||||
/**
|
||||
* Shell behavior support.
|
||||
*/
|
||||
export type ShellBehavior =
|
||||
| "bash_sh_commands"
|
||||
| "process_signals"
|
||||
| "sudo"
|
||||
| "package_manager_commands"
|
||||
| "timeout_kill"
|
||||
|
||||
/**
|
||||
* GUI/Debug/Network evidence support.
|
||||
*/
|
||||
export type EvidenceCapability =
|
||||
| "screenshots"
|
||||
| "gui_automation"
|
||||
| "pcaps"
|
||||
| "core_dumps"
|
||||
| "debugger_integration"
|
||||
|
||||
/**
|
||||
* Feature tier mapping for runtime features.
|
||||
* Maps runtime feature to support level per platform.
|
||||
*/
|
||||
export interface RuntimeFeatureTier {
|
||||
feature: RuntimeFeature
|
||||
linux_x86_64: PlatformSupportLevel
|
||||
linux_arm64: PlatformSupportLevel
|
||||
macOS: PlatformSupportLevel
|
||||
windows_native: PlatformSupportLevel
|
||||
wsl2: PlatformSupportLevel
|
||||
}
|
||||
|
||||
/**
|
||||
* Toolchain feature tier mapping.
|
||||
*/
|
||||
export interface ToolchainFeatureTier {
|
||||
feature: ToolchainFeature
|
||||
linux_x86_64: PlatformSupportLevel
|
||||
linux_arm64: PlatformSupportLevel
|
||||
macOS: PlatformSupportLevel
|
||||
windows_native: PlatformSupportLevel
|
||||
wsl2: PlatformSupportLevel
|
||||
}
|
||||
Reference in New Issue
Block a user