Commit Graph
198 Commits
Author SHA1 Message Date
ZacharyZhang-NY b8dda3c8d0 update 2026-04-04 17:01:26 -04:00
ZacharyZhang-NY 67c757f481 update 2026-04-04 12:03:50 -04:00
ZacharyZhang-NY 65e85135c1 large update 2026-03-29 14:08:15 -04:00
ZacharyZhang-NY 29e4f9f430 Merge branch 'worktree-agent-a8526086'
# Conflicts:
#	.planning/STATE.md
2026-03-28 03:19:28 -04:00
ZacharyZhang-NYandClaude Opus 4.6 4b5492ea34 feat(quick-260328-48g): add database methods for heartbeat task reuse and cleanup
- Add findReusableHeartbeatTask() to find most recent done/in_review heartbeat task per agent
- Add cleanupDuplicateHeartbeatTasks() to cancel old duplicates using ROW_NUMBER window function
- Add 12 unit tests covering coalescing behavior, cross-agent isolation, status filtering

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 03:14:40 -04:00
ZacharyZhang-NY c395dbe8bf test(10-02): session rotation during execution edge case tests (D-05.3)
- Rotation triggered when run count exceeds maxRuns threshold
- Rotation triggered when token count exceeds maxTokens threshold
- Handoff markdown generated with task title and run history
- New session after rotation has clean counters (0 runs, 0 tokens)
- Claude connector exempt from rotation (nativeContextManagement)
- Codex connector exempt from rotation (nativeContextManagement)
- Handoff markdown available for next run context after rotation
2026-03-27 20:32:45 -04:00
ZacharyZhang-NY 2f80c319f9 test(10-02): budget exhaustion mid-run edge case tests (D-05.2)
- In-flight run completes normally when budget exhausted by another run
- Budget gate blocks next run after exhaustion
- BlockedBy returns detailed policy/scope/spent/limit info
- Agent-scope exhaustion blocks even when company budget has room
- Budget gate transitions from allowed to blocked after spending
- Cost entry recorded even when budget would be exceeded
2026-03-27 20:31:44 -04:00
ZacharyZhang-NY e14964ade3 test(10-02): concurrent checkout edge case tests (D-05.1)
- CAS rejects second claimer when two agents attempt same task
- Losing agent can checkout a different task
- In-progress status guard blocks new checkouts
- Lock release clears fields but CAS still checks status
- Stale lock recovery frees locks and resets status to todo
- Recovered task can be re-checked-out by another agent
- STALE_LOCK_TIMEOUT_MS validated at 15 minutes
2026-03-27 20:30:34 -04:00
ZacharyZhang-NYandClaude Opus 4.6 41c5dccae4 feat(09-02): wire App.tsx granular event routing with batch handler
- Replace createEventBatcher with createDomainEventBatcher in App.tsx
- Add handleGranularBatch for task, run, approval, agent, and budget events
- Task/run/approval events trigger targeted IPC fetch and Zustand patch
- Run completion and budget changes trigger full refresh (cross-entity)
- Failed entity fetches fall back to removeTask or full refresh
- Unknown event types trigger full refresh (PERF-03 safety)
- Sidebar badges refresh after every successful granular batch
- Add 12 integration tests for handleGranularBatch in selective-ipc.test.ts

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 19:49:55 -04:00
ZacharyZhang-NY 039c1d117f Merge branch 'worktree-agent-a2f30682'
# Conflicts:
#	.planning/STATE.md
#	src/main/ipc-core-read-handlers.ts
#	src/shared/contracts.ts
2026-03-27 19:40:29 -04:00
ZacharyZhang-NYandClaude Opus 4.6 f172a3d9b3 feat(09-01): build enhanced event batcher with granular event coalescing
- Add createDomainEventBatcher with entity type+ID dedup within 50ms window
- Domain-changed overrides all granular events in same batch
- More than 10 unique entities triggers full refresh fallback
- Delete action preserved during coalescing (last-write-wins otherwise)
- Unknown event types trigger full refresh as safety fallback
- Legacy createEventBatcher preserved for backward compatibility
- Add 12 comprehensive tests for all coalescing behaviors

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 19:35:05 -04:00
ZacharyZhang-NYandClaude Opus 4.6 920a764856 feat(09-01): define granular event types, IPC channels, entity getters, and Zustand patch methods
- Add 5 granular event interfaces (TaskUpdated, RunUpdated, ApprovalUpdated, AgentUpdated, BudgetChanged) to DesktopEvent union
- Add 4 entity getter IPC channels (getTask, getAgent, getRun, getApproval) with Zod validation and company ownership checks
- Add getRun method to AppDatabase following existing getTask pattern
- Add 4 preload bridge methods for entity getters
- Add 8 patch/remove methods and refreshBadges to CompanySlice
- Add selective-ipc.test.ts with exhaustive union type tests
- Extend store.test.ts with 14 patch method tests

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 19:33:33 -04:00
ZacharyZhang-NY 40b01f24e9 Merge branch 'worktree-agent-a1f54db6'
# Conflicts:
#	.planning/STATE.md
2026-03-27 08:51:34 -04:00
ZacharyZhang-NYandClaude Opus 4.6 a45e6bc10c feat(08-01): install Recharts and create tested data aggregation functions
- Install recharts@3.8.1 as dependency
- Create chart-utils.ts with 4 exported pure functions: aggregateRunsByDay, aggregateCostsByDay, aggregateAgentWorkload, formatShortDate
- Create dashboard-charts.test.ts with 16 unit tests covering all aggregation behaviors
- All tests pass: 14-day bucketing with zero-fill, timed_out/interrupted as failed, null cost handling, top-8 + Others grouping, name truncation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 08:44:49 -04:00
ZacharyZhang-NY fd3f5accc1 Merge branch 'worktree-agent-a205edfb'
# Conflicts:
#	.planning/STATE.md
#	src/main/orchestration-service.ts
#	src/main/task-quality-gates.ts
#	tests/unit/task-quality-gates.test.ts
2026-03-27 00:47:58 -04:00
ZacharyZhang-NYandClaude Opus 4.6 c4eb4423db feat(07-02): wire sweepStaleReviews into heartbeat timer
- Import sweepStaleReviews, resolveApprovalDecision, dispatchAgentMessage
- Insert stale review sweep into per-company heartbeat loop after budget reset
- Sweep runs on every 15-second heartbeat cycle for each active company
- Local callback stubs for handleTaskStatusChange and handleApprovalResolved
- Error handling prevents sweep failures from crashing the heartbeat loop
- Fix test type casts to use as-unknown-as for vi.fn mock compatibility
- TypeScript compiles cleanly, 249/249 tests pass

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 00:43:08 -04:00
ZacharyZhang-NYandClaude Opus 4.6 e1f8a3c9ab test(07-02): add failing tests for sweepStaleReviews escalation
- 8 tests covering TASK-04 stale review escalation logic
- Escalation to manager's manager, CEO fallback notification
- Auto-approve pending approvals, race condition handling
- Task status advancement, no-assignee skip, timeout constant

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 00:38:57 -04:00
ZacharyZhang-NYandClaude Opus 4.6 4d1085fc04 chore(07-02): bring in plan 01 prerequisites
Cherry-pick plan 01 task quality gate validation module and its
integration into IPC, API server, and automation service.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 00:37:36 -04:00
ZacharyZhang-NY 8ef70259e0 Merge branch 'worktree-agent-a3712f2b'
# Conflicts:
#	.planning/STATE.md
2026-03-27 00:34:55 -04:00
ZacharyZhang-NY d38b59255c test(07-01): add failing tests for task quality gate validation
- validateTaskCreation: description length, heartbeat bypass, acceptance criteria
- checkAcceptanceCriteria: keyword detection for 12 patterns
- checkCapabilityMatch: capability overlap, skill fallback, graceful degradation
2026-03-27 00:26:25 -04:00
ZacharyZhang-NYandClaude Opus 4.6 5271f7ee5d feat(06-02): wire token usage tracking, session accumulation, and rotation into worker pipeline
- Add inputTokens/outputTokens fields to worker run-finished messages and workerMessageSchema
- Wire sessionService into WorkerServiceDependencies and ServiceGraph lazy slot
- Add token accumulation and rotation evaluation in run-finished handler
- Add 7 wiring integration tests verifying accumulation, rotation, and guard paths

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 23:03:23 -04:00
ZacharyZhang-NYandClaude Opus 4.6 e54c632fd6 feat(06-01): add session management service with rotation, thresholds, and delta tracking
- Create createSessionManagementService factory with accumulateTokenUsage,
  evaluateRotation (configurable thresholds per D-01), generateHandoff,
  rotateSession, getHandoffContext, snapshotUsage, getUsageDelta
- Export DEFAULT_THRESHOLDS (maxRuns: 20, maxTokens: 500k, maxAgeHours: 72) and RotationThresholds type
- Adapter nativeContextManagement exemption skips rotation for Claude/Codex (D-04)
- Handoff markdown capped at 2000 chars with structured sections (D-06)
- Add 14 unit tests for service: rotation thresholds, adapter exemption, configurable
  thresholds, token accumulation, handoff generation, session rotation, usage delta

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 22:56:18 -04:00
ZacharyZhang-NYandClaude Opus 4.6 2c671d0011 feat(06-01): add task_sessions CRUD, nativeContextManagement flag, TaskSessionRecord type
- Add getActiveTaskSession, incrementSessionUsage, archiveSession, createNewSession,
  getRecentRunsForTask, getRecentActivityForTask methods to AppDatabase
- Add nativeContextManagement optional boolean to ServerAdapterModule interface
- Set nativeContextManagement: true for claude_local and codex_local, false for gemini_local
- Add TaskSessionRecord interface to shared types
- Add unit tests for task_sessions CRUD and adapter exemption flags

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 22:53:39 -04:00
ZacharyZhang-NYandClaude Opus 4.6 245eb4ccf3 test(05-01): add tests for budget policy evaluation and incident lifecycle
- Budget policy CRUD (save, update, delete)
- getActivePoliciesForRun with multi-scope matching
- getSpentInWindow with cents aggregation per scope (company/agent/project)
- evaluateBudgetGate strictest-wins logic (D-01)
- upsertBudgetIncident with deduplication (D-08)
- resolveIncidentsForPolicy and autoCloseExpiredIncidents (D-06)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 20:43:50 -04:00
ZacharyZhang-NY 63ff0f2625 Merge branch 'worktree-agent-a1383b58'
# Conflicts:
#	.planning/STATE.md
#	src/main/database.ts
2026-03-26 19:07:13 -04:00
ZacharyZhang-NY 4d47712669 fix(04-01): resolve type errors and update integration tests for wakeup API
- Fix SQLInputValue type in listWakeupRequests params
- Fix leftover pendingWakes reference in worker-service.ts
- Fix RunStatus 'completed' -> 'succeeded' in atomic-checkout test
- Update autonomous-chain.spec.ts to use new wakeup lifecycle API
2026-03-26 19:00:51 -04:00
ZacharyZhang-NY f647a4fdf1 test(04-01): add wakeup lifecycle unit tests covering all CRUD operations
- 10 test cases: enqueue, coalesce (queued + deferred), claim, complete, defer, promote, merge, list with filters
- Validates D-06 trigger_detail JSON array coalescing
- Validates D-07 per-agent scope deduplication
- Validates full state machine: queued -> claimed -> completed, queued -> deferred -> queued
2026-03-26 18:58:18 -04:00
ZacharyZhang-NY 08935b3379 feat(04-01): implement CAS checkout, lock release, stale recovery, and migration 16
- Rewrite checkoutTask to use runId-based CAS with checkout_run_id IS NULL guard
- Add releaseTaskLock and recoverStaleLocks methods
- Add lock release in finishRun and cancelRunForDeletion exit paths
- Add migration 16: pending_wakes to wakeup_requests cutover with DROP TABLE
- Replace all pending_wakes references with wakeup_requests
- Add wakeup lifecycle CRUD: enqueue, claim, complete, defer, promote, list
- Update api-server, orchestration-service, worker-service callers
- Update existing database.test.ts for new checkoutTask signature
2026-03-26 18:56:54 -04:00
ZacharyZhang-NY 02e87dc06d test(04-01): add failing tests for CAS checkout, lock release, stale recovery
- 8 test cases covering CAS semantics, lock release on finishRun/deleteAgent, stale recovery
- Tests expect STALE_LOCK_TIMEOUT_MS export, checkout_run_id/execution_locked_at columns
- RED phase: 5 of 8 tests fail as expected before implementation
2026-03-26 18:51:46 -04:00
ZacharyZhang-NY 77480374fd test(02-01): add failing test for canonical key derivation
- Tests normalizeSkillSlug for edge cases (empty, null, special chars)
- Tests hashSkillValue determinism and 10-char hex output
- Tests deriveCanonicalSkillKey for all 5 source types
- Tests parseSkillImportSource for GitHub, skills.sh, URL, local paths
2026-03-26 00:26:56 -04:00
ZacharyZhang-NY 58d3f4a039 test(02-01): add failing test for SKILL.md format parser
- Tests parseFrontmatterMarkdown with frontmatter, no frontmatter, CRLF normalization
- Tests classifyInventoryKind for all file type classifications
- Tests deriveTrustLevel for script/asset/markdown-only derivation
- Tests estimateTokens for token estimation logic
2026-03-26 00:24:53 -04:00
ZacharyZhang-NY f16ddc44f9 test(02-01): add failing test for skill type definitions
- Tests TOKEN_BUDGETS constant values for 5 adapter types
- Tests type shapes for SkillRecord, RuntimeSkillEntry, ManagedSkillRef
- Tests SkillSourceType (5 members), TrustLevel (3 members), FileInventoryEntry (6 kinds)
2026-03-26 00:23:45 -04:00
ZacharyZhang-NYandClaude Opus 4.6 5b1fc8a105 fix(test): correct secret scoping test — literal fallback is expected behavior
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 23:45:01 -04:00
ZacharyZhang-NYandClaude Opus 4.6 9ebb489644 feat(04-01): create notification service with batching, urgency, and GC protection
- Add createNotificationService with 10s batch window, urgency mapping, click-to-navigate
- Extend DesktopEvent union with NotificationClickEvent type
- Add 10 unit tests covering batching, urgency, NEVER_BATCH, GC protection, Linux urgency
- Platform-specific: silent flag, Windows timeoutType, Linux urgency level

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 16:30:49 -04:00
ZacharyZhang-NY 43cb97ac6d feat(03-02): add SocialDraftPreview component and ApprovalInspector integration
- Create SocialDraftPreview with platform icon, color, content, char count, media URLs, schedule display
- Integrate SocialDraftPreview into ApprovalInspector for social_post approvals
- Add schedule picker with immediate/scheduled radio group and datetime-local input
- Add social_post to type badge with accent styling
- Approve button shows 'Approve & Post' for social_post approvals
- Accessibility: role=region, aria-label, aria-live=polite, role=radiogroup
- Fix test type annotation for TS compatibility
2026-03-22 14:33:47 -04:00
ZacharyZhang-NY e0ee5bb5ad feat(03-02): implement social draft pipeline backend
- Add social_post to ApprovalType union in types.ts
- Add social_post to approvalInputSchema enum in contracts.ts
- Add POST /api/companies/:companyId/social/draft endpoint in api-server.ts
- Add social_post handling in handleApprovalResolved in automation-service.ts
- Browser action payloadJson includes scheduledAt for startup recovery (03-03 contract)
- Scheduled posts use setTimeout for deferred dispatch
- All 13 unit tests pass
2026-03-22 14:30:32 -04:00
ZacharyZhang-NY ce2c3be065 feat(03-01): add searchMessages backend with LIKE query, IPC channel, preload bridge, and tests
- Add searchMessages method to AppDatabase with LIKE query, wildcard escaping, channel scoping, ORDER BY created_at DESC with limit
- Add searchMessages IPC channel and searchMessagesSchema to contracts.ts
- Register IPC handler in ipc-agent-coordination-handlers.ts with Zod validation
- Wire searchMessages through preload bridge
- Add 8 unit tests covering body/subject search, wildcard escaping, channel scoping, empty results, limit, and ordering
2026-03-22 14:29:59 -04:00
ZacharyZhang-NY 14da6b5ede feat(03-03): add budget alert OS notifications and scheduled post recovery
- Add notify() calls at 80% budget threshold warning and 100% exhaustion auto-pause
- Compute percentage as Math.round(utilization * 100) for accurate display
- Add scheduled social post timer re-registration on app startup
- Add unit tests for budget threshold detection and notification logic
2026-03-22 14:29:43 -04:00
ZacharyZhang-NY 8558b113a2 test(03-02): add failing tests for social draft pipeline
- Social draft schema validation tests (valid input, defaults, rejections)
- social_post as valid ApprovalType test (currently fails - not yet added)
- payloadSummary truncation logic tests
- Approval resolution logic: immediate dispatch, deferred dispatch, rejected drafts
- Cross-plan contract: browser action payloadJson includes scheduledAt
2026-03-22 14:27:26 -04:00
ZacharyZhang-NY 64183428ec feat(02-03): crash recovery detection and user notification
- Enhance interruptStaleRuns to return count and mark tasks as blocked
- Add lastInterruptedCount property for bootstrap recovery check
- Add getInterruptedRunsForRecovery query method
- Add retryInterruptedTask, dismissInterruptedTask, markInterruptedTaskFailed actions
- Add recovery-needed IPC event emission in bootstrap between heartbeat and resume
- Create ipc-recovery-handlers.ts with retry/dismiss/fail IPC handlers
- Register recovery handlers in domain handler chain
- Expose recoveryRetry, recoveryDismiss, recoveryFail in preload API
- Add recovery method types to DesktopApi contract
- Create RecoveryBanner component with retry/cancel per interrupted task
- Integrate RecoveryBanner at top of Dashboard view
- Add crash recovery unit tests (9 tests)
2026-03-22 03:57:58 -04:00
ZacharyZhang-NY f3874568a2 feat(02-03): retry-aware failure escalation pipeline
- Add MAX_RETRY_ATTEMPTS (2) and RETRY_COOLDOWN_MS (30s) constants
- Replace immediate escalation with retry-then-escalate logic
- Escalation chain: retry same agent -> manager -> CEO -> user notification
- Reset retry count on successful task completion
- Update Reassign on run failure automation rule with afterRetryExhaustion condition
- Add comprehensive unit tests for escalation state machine (11 tests)
2026-03-22 03:53:18 -04:00
ZacharyZhang-NY 46dee6c66b test(02-02): add circuit breaker and deliverable enforcement tests
- Self-wake circuit breaker tests: trip after 5 wakes, reset on progress, per-agent isolation
- Non-code task deliverable tests: research/content require artifacts, code/general advance normally
2026-03-22 03:52:12 -04:00
ZacharyZhang-NY d09b7445e5 test(02-01): add failing tests for connector-matching heuristic
- 24 test cases covering matchConnector, inferTaskType, getConnectorStrengths
- Tests for preference mapping, fallback behavior, edge cases
- TDD RED phase: module does not exist yet
2026-03-22 03:41:41 -04:00
ZacharyZhang-NY d77486504d feat(01-04): add TanStack Virtual list virtualization and keyboard navigation hook
- Install @tanstack/react-virtual for virtualized list rendering
- Create useRovingTabIndex hook in src/renderer/lib/keyboard.ts for arrow-key navigation
- Add virtualization to 6 lists: TaskQueue, ApprovalList, ActivityList, CostList, AgentRoster, MessageList
- MessageList uses measureElement for variable-height message items with auto-scroll
- All 6 lists have role="listbox" with role="option" on rows for accessibility
- All 6 lists support ArrowDown/ArrowUp/j/k/Home/End keyboard navigation
- Add 8 unit tests for useRovingTabIndex covering all key bindings and edge cases
2026-03-22 02:08:43 -04:00
ZacharyZhang-NYandClaude Opus 4.6 5e9d36c058 feat(01-01): create Zustand store with 6 slices, IPC batcher, and unit tests
- Install zustand 5.x and immer 11.x dependencies
- Create 6 Zustand slices: navigation, company, selection, ui, communication, social
- Create combined store with devtools + immer middleware
- Create IPC event batcher with 50ms debounce window (schedule/flush/dispose)
- Create typed selector hooks for narrow state subscriptions
- Add 14 unit tests covering store initialization, slice behaviors, and batcher timing

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 01:30:37 -04:00
ZacharyZhang-NY 1ba3147ed2 update 2026-03-18 01:15:58 -04:00
ZacharyZhang-NY 7a3db27ffa update 2026-03-17 12:31:06 -04:00
ZacharyZhang-NY 2af82b6bb3 Initialize project and ignore local references 2026-03-15 22:17:07 -04:00