From deb1f8d2d2bc075f5f120132f954e457d3264e47 Mon Sep 17 00:00:00 2001 From: rUv Date: Tue, 13 Jan 2026 15:35:57 +0000 Subject: [PATCH] Checkpoint: File edits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automatic checkpoint created by Claude Code - Branch: v3 - Timestamp: 2026-01-13T15:35:57Z - Changes: 6 file(s) πŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- agents/architect.yaml | 2 +- agents/coder.yaml | 2 +- agents/reviewer.yaml | 2 +- agents/security-architect.yaml | 2 +- agents/tester.yaml | 2 +- .../adrs/ADR-025-auto-update-system.md | 268 ++++++++++++++++++ 6 files changed, 273 insertions(+), 5 deletions(-) create mode 100644 v3/implementation/adrs/ADR-025-auto-update-system.md diff --git a/agents/architect.yaml b/agents/architect.yaml index 5095c42574..657442e566 100644 --- a/agents/architect.yaml +++ b/agents/architect.yaml @@ -8,4 +8,4 @@ capabilities: optimizations: - context-caching - memory-persistence -createdAt: "2026-01-12T18:35:04.019Z" +createdAt: "2026-01-13T15:29:56.249Z" diff --git a/agents/coder.yaml b/agents/coder.yaml index 5565f2d92a..566fceaa0d 100644 --- a/agents/coder.yaml +++ b/agents/coder.yaml @@ -8,4 +8,4 @@ capabilities: optimizations: - flash-attention - token-reduction -createdAt: "2026-01-12T18:35:04.018Z" +createdAt: "2026-01-13T15:29:56.248Z" diff --git a/agents/reviewer.yaml b/agents/reviewer.yaml index 2ed0ca9491..8cbdb8645a 100644 --- a/agents/reviewer.yaml +++ b/agents/reviewer.yaml @@ -7,4 +7,4 @@ capabilities: - best-practices optimizations: - incremental-analysis -createdAt: "2026-01-12T18:35:04.019Z" +createdAt: "2026-01-13T15:29:56.249Z" diff --git a/agents/security-architect.yaml b/agents/security-architect.yaml index 1b524e9d29..58c6debead 100644 --- a/agents/security-architect.yaml +++ b/agents/security-architect.yaml @@ -7,4 +7,4 @@ capabilities: - security-review optimizations: - pattern-matching -createdAt: "2026-01-12T18:35:04.019Z" +createdAt: "2026-01-13T15:29:56.249Z" diff --git a/agents/tester.yaml b/agents/tester.yaml index 795c4fc9fe..5b9173e278 100644 --- a/agents/tester.yaml +++ b/agents/tester.yaml @@ -7,4 +7,4 @@ capabilities: - coverage optimizations: - parallel-execution -createdAt: "2026-01-12T18:35:04.019Z" +createdAt: "2026-01-13T15:29:56.249Z" diff --git a/v3/implementation/adrs/ADR-025-auto-update-system.md b/v3/implementation/adrs/ADR-025-auto-update-system.md new file mode 100644 index 0000000000..72c7bd66ea --- /dev/null +++ b/v3/implementation/adrs/ADR-025-auto-update-system.md @@ -0,0 +1,268 @@ +# ADR-025: Auto-Update System for @claude-flow Packages + +## Status +**Accepted** - 2026-01-13 + +## Context + +The Claude Flow V3 ecosystem consists of multiple packages: +- `@claude-flow/cli` - Main CLI tool +- `@claude-flow/embeddings` - Vector embeddings +- `@claude-flow/security` - Security utilities +- `@claude-flow/integration` - agentic-flow integration +- `@claude-flow/testing` - Test utilities + +When one package is updated, dependent packages may need updates for compatibility. Currently, users must manually check for updates, leading to: +- Version mismatches causing runtime errors +- Missing security patches +- Delayed access to performance improvements +- Inconsistent behavior across installations + +## Decision + +Implement an **auto-update system** that: + +1. **Checks for updates on startup** (with rate limiting) +2. **Validates package compatibility** before updating +3. **Auto-updates minor/patch versions** (configurable) +4. **Notifies users** of major version updates +5. **Maintains update history** for rollback capability + +### Update Check Frequency + +| Trigger | Behavior | +|---------|----------| +| First run of day | Full update check | +| Subsequent runs same day | Skip check (use cache) | +| `--force-update` flag | Force immediate check | +| `--no-update` flag | Skip all update checks | +| CI/CD environment | Skip by default | + +### Package Priority + +| Priority | Packages | Auto-Update | +|----------|----------|-------------| +| Critical | `@claude-flow/security` | Always (patches) | +| High | `@claude-flow/cli` | Minor + Patch | +| Normal | `@claude-flow/embeddings`, `@claude-flow/integration` | Patch only | +| Low | `@claude-flow/testing` | Notify only | + +## Implementation + +### Architecture + +``` +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ CLI Startup β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ + β–Ό +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ UpdateChecker Service β”‚ +β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ +β”‚ β”‚ RateLimiter β”‚ β”‚ NPM Registryβ”‚ β”‚ Version Compare β”‚ β”‚ +β”‚ β”‚ (24h cache) β”‚ β”‚ Client β”‚ β”‚ (semver) β”‚ β”‚ +β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ + β–Ό +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ PackageValidator β”‚ +β”‚ - Dependency compatibility check β”‚ +β”‚ - Peer dependency verification β”‚ +β”‚ - Breaking change detection β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ + β–Ό +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ UpdateExecutor β”‚ +β”‚ - npm install with specific versions β”‚ +β”‚ - Rollback on failure β”‚ +β”‚ - Update history logging β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ +``` + +### Core Components + +#### 1. UpdateChecker (`src/update/checker.ts`) + +```typescript +interface UpdateCheckResult { + package: string; + currentVersion: string; + latestVersion: string; + updateType: 'major' | 'minor' | 'patch' | 'none'; + shouldAutoUpdate: boolean; + changelog?: string; +} + +interface UpdateConfig { + enabled: boolean; + checkIntervalHours: number; // Default: 24 + autoUpdatePatch: boolean; // Default: true + autoUpdateMinor: boolean; // Default: false + autoUpdateMajor: boolean; // Default: false + excludePackages: string[]; // Packages to skip + priorityPackages: string[]; // Check these first +} +``` + +#### 2. RateLimiter (`src/update/rate-limiter.ts`) + +```typescript +interface RateLimitState { + lastCheck: string; // ISO timestamp + checksToday: number; + packageVersions: Record; +} + +// Stored in: ~/.claude-flow/update-state.json +``` + +#### 3. PackageValidator (`src/update/validator.ts`) + +```typescript +interface ValidationResult { + valid: boolean; + incompatibilities: string[]; + warnings: string[]; + requiredPeerUpdates: string[]; +} +``` + +### Update Flow + +``` +1. CLI Start + β”‚ + β”œβ”€β–Ί Check rate limit cache (~/.claude-flow/update-state.json) + β”‚ └─► If checked within 24h AND no --force-update β†’ Skip + β”‚ + β”œβ”€β–Ί Query npm registry for @claude-flow/* packages + β”‚ └─► Compare versions using semver + β”‚ + β”œβ”€β–Ί For each package with available update: + β”‚ β”œβ”€β–Ί Check update priority (critical/high/normal/low) + β”‚ β”œβ”€β–Ί Validate compatibility with other packages + β”‚ └─► Determine if auto-update applies + β”‚ + β”œβ”€β–Ί Execute auto-updates (if any) + β”‚ β”œβ”€β–Ί npm install @claude-flow/package@version + β”‚ β”œβ”€β–Ί Verify installation success + β”‚ └─► Log to update history + β”‚ + └─► Display notification for non-auto updates + └─► "Run `npx claude-flow update` to update X packages" +``` + +### CLI Commands + +```bash +# Check for updates (manual) +npx claude-flow update check + +# Update all packages +npx claude-flow update all + +# Update specific package +npx claude-flow update @claude-flow/embeddings + +# View update history +npx claude-flow update history + +# Rollback last update +npx claude-flow update rollback + +# Configure auto-update +npx claude-flow config set update.autoUpdateMinor true +npx claude-flow config set update.checkIntervalHours 12 +``` + +### Environment Variables + +```bash +# Disable auto-update entirely +CLAUDE_FLOW_AUTO_UPDATE=false + +# Force update check +CLAUDE_FLOW_FORCE_UPDATE=true + +# CI/CD mode (no interactive prompts, no auto-update) +CI=true +``` + +### Configuration File + +```json +// claude-flow.config.json +{ + "update": { + "enabled": true, + "checkIntervalHours": 24, + "autoUpdate": { + "patch": true, + "minor": false, + "major": false + }, + "priority": { + "@claude-flow/security": "critical", + "@claude-flow/cli": "high", + "@claude-flow/embeddings": "normal", + "@claude-flow/integration": "normal", + "@claude-flow/testing": "low" + }, + "exclude": [] + } +} +``` + +## Security Considerations + +1. **Registry verification**: Only fetch from official npm registry +2. **Checksum validation**: Verify package integrity before install +3. **Rollback capability**: Maintain previous versions for quick rollback +4. **Audit logging**: Log all update operations for traceability +5. **Signature verification**: Verify npm package signatures when available + +## Consequences + +### Positive +- Users always have latest security patches +- Reduced version mismatch issues +- Improved ecosystem consistency +- Automatic performance improvements +- Reduced support burden + +### Negative +- Slightly slower startup (mitigated by rate limiting) +- Requires network access (gracefully degrades offline) +- Potential for breaking changes (mitigated by validation) + +### Neutral +- Additional storage for update state (~1KB) +- New CLI commands to learn + +## Alternatives Considered + +1. **No auto-update**: Rejected - too many version mismatch issues +2. **Update on every run**: Rejected - too slow, network overhead +3. **Weekly update check**: Rejected - security patches delayed too long +4. **npm-check-updates integration**: Rejected - external dependency + +## Implementation Plan + +| Phase | Task | Priority | +|-------|------|----------| +| 1 | UpdateChecker service | High | +| 2 | RateLimiter with file cache | High | +| 3 | PackageValidator | High | +| 4 | UpdateExecutor with rollback | Medium | +| 5 | CLI commands | Medium | +| 6 | Configuration integration | Medium | +| 7 | Telemetry/logging | Low | + +## References + +- [npm registry API](https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md) +- [semver specification](https://semver.org/) +- [ADR-013: Core Security Module](./ADR-013-core-security-module.md)