Skip to content

Refactor repository structure and agent harness - #8

Merged
RojhatToptamus merged 2 commits into
mainfrom
codex/repository-structure-and-agent-harness
Jul 21, 2026
Merged

Refactor repository structure and agent harness#8
RojhatToptamus merged 2 commits into
mainfrom
codex/repository-structure-and-agent-harness

Conversation

@RojhatToptamus

@RojhatToptamus RojhatToptamus commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Summary

This PR applies the repository-wide structural refactor and agent-harness improvements identified during the architecture review while preserving Task Monki's workflow, evidence, provider, storage, and protocol invariants.

Repository and architecture boundaries

  • Enforces dependency direction, cycle detection, provider isolation, and Electron IPC parity through architecture checks used locally and in CI/release workflows.
  • Clarifies ownership across core domain/orchestration, provider adapters, renderer model code, presentation code, shared contracts, and tests.
  • Keeps provider telemetry separate from Task Monki's authoritative workflow state and verified local Git, test, and GitHub evidence.

Renderer structure

  • Extracts pure renderer selectors and view-model responsibilities from large presentation modules.
  • Splits the largest application, task-detail, main-column, and preview surfaces into focused components with meaningful responsibilities.
  • Reorganizes the monolithic renderer stylesheet into ordered feature stylesheets while preserving the existing cascade.
  • Adds a mounted JSDOM interaction harness alongside focused model and SSR tests.

Backend structure

  • Introduces narrow, behavior-backed seams for runtime composition, Discourse runtime hosting, operation gating, settings/transition policies, ACP native sessions, and preview execution ownership/failure handling.
  • Centralizes task-store normalization and formalizes the development seed scenario catalog.
  • Preserves durable storage shapes and avoids generated Codex protocol changes.
  • Hardens GitHub review rollup persistence after packaged Electron testing exposed a blank review-decision writer/validator mismatch. Current-schema stores created by the affected writer are repaired narrowly and atomically on load; all other malformed data remains fail-closed.

Agent harness and documentation

  • Adds targeted test commands and machine-checkable architecture constraints so agents can verify smaller changes quickly and detect boundary regressions early.
  • Adds a typed Electron IPC manifest plus parity coverage for main/preload API registration.
  • Bounds core test concurrency for the subprocess-heavy suite, eliminating resource-contention timeouts observed during the full acceptance pass.
  • Updates repository and architecture/workflow documentation to explain current ownership, navigation, invariants, and verification paths.

Why

Responsibilities had accumulated in a few large composition roots and UI modules, while important dependency rules were mostly implicit. Tests existed but were harder for agents and maintainers to discover and run by subsystem. This increased change risk and slowed feedback.

The refactor uses incremental extraction and enforceable boundaries rather than a broad rewrite. Backend changes follow verified behavior and existing state ownership; no speculative domain layers or compatibility abstractions were introduced.

Packaged Electron acceptance testing

The built macOS ARM64 Electron application was exercised against an isolated user-data profile and the disposable RojhatToptamus/test-monki repository. The pass covered both success and failure states and included application restarts.

  • First-launch setup, repository selection, task creation, agent refinement, model/effort selection, isolated worktree creation, and task execution.
  • Live agent activity, plan/tool telemetry, a failed implementation run, detached review, request-changes follow-up, stale-review handling, and a fresh passing review.
  • Real provider executions through Codex, Grok Build, Cursor Agent, and OpenCode, including a command-approval flow and exact-file-content validation.
  • Agent Discourse with read-only repository context and persistence of the conversation after restart.
  • Preview setup-required state, Vite capability discovery limitation, manual recipe discovery, approval, install/start, stable-route launch, browser reachability, replacement/recovery, stop/delete confirmation, cleanup, and post-stop 503 validation.
  • Commit, push, draft PR creation in the disposable repository, failed GitHub checks, rerun/recovery, and refreshed passing delivery evidence in the Electron UI.
  • Persistence after restart for tasks, provider runs, Discourse history, PR evidence, and stopped-preview state.

The acceptance pass discovered the blank GitHub review-decision persistence defect described above. The exact rejected profile was retained, the fix was applied, the packaged app was rebuilt, and that same profile then loaded successfully with the invalid field durably removed.

Verification

  • npm run verify
    • TypeScript typecheck passed.
    • Architecture check passed for 284 production files.
    • Core suite: 229 files passed, 1 skipped; 1,836 tests passed, 15 skipped.
    • Mounted renderer DOM suite: 2 tests passed.
    • Generated Codex protocol: 576 files matched the pinned metadata.
    • Production build passed (the existing renderer chunk-size warning remains).
  • Targeted GitHub/storage regression suite: 82 tests passed, 1 skipped.
  • npm run dist:dir and packaged Electron launch/restart passed.
  • Disposable Vite application production build passed.
  • git diff --check passed.

Independent review

The structural changes were reviewed independently from backend and frontend/agent-harness perspectives. Earlier review findings involving shutdown gating, stale documentation references, and unintentional extraction drift were corrected.

The E2E-discovered storage repair and test-harness change received a separate follow-up review. It confirmed that the repair is current-schema-only, field/value-specific, idempotent, atomically persisted, and still subject to full record/relationship validation. No actionable findings remain.

Risks and validation limits

  • Automatic preview recipe generation currently recognizes Next.js 15/16 capabilities but not a standard Vite project. The Vite fixture correctly reported that more evidence was needed; it was then exercised end-to-end through an explicit .taskmonki/preview.yaml recipe. If automatic Vite discovery is a release requirement, that remains follow-up work.
  • An externally added preview recipe was discovered after application restart rather than live-reloaded.
  • Claude ACP was reported as not installed and was not exercised. Codex, Grok Build, Cursor Agent, and OpenCode were exercised successfully.
  • The disposable delivery PR was intentionally left draft and unmerged, so final merge-state projection was not exercised.
  • The real OCI Compose integration test remains intentionally skipped; this Vite fixture did not require managed database/cache cleanup.
  • Hosted macOS, Linux, and Windows workflows were inspected but cannot all be executed locally.
  • The existing approximately 750 kB minified renderer chunk warning remains outside this structural refactor.
  • A production dependency audit reports no production vulnerabilities. Development-tooling upgrades with breaking Electron/electron-builder/esbuild changes remain outside this PR.
  • No stored schema version or generated provider protocol files were changed.

@RojhatToptamus
RojhatToptamus marked this pull request as ready for review July 21, 2026 16:14
@RojhatToptamus
RojhatToptamus merged commit 60b2ea4 into main Jul 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant