Skip to content

chore(agent-harness): register workspaces and enforce CI boundaries - #5632

Closed
iscekic wants to merge 5 commits into
mainfrom
shared-agent-harness-3bb0
Closed

chore(agent-harness): register workspaces and enforce CI boundaries#5632
iscekic wants to merge 5 commits into
mainfrom
shared-agent-harness-3bb0

Conversation

@iscekic

@iscekic iscekic commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

No new behavior — This foundation adds development checks and prepares later agent work without changing how people use the product.


Summary

@kilocode/agent-harness exposes only AGENT_HARNESS_PROTOCOL_VERSION = 1; this change does not implement the harness runtime or client hosts. Its export map reserves @kilocode/agent-harness/react and TypeScript subpaths, and blocks test imports. React 19 stays optional so non-React consumers can use the portable core without a React dependency.

Files
  • packages/agent-harness/package.json — registers the private package, exports, gateway/Zod dependencies, and test, typecheck, lint, and format commands (source; added; 38 changed lines).
  • packages/agent-harness/src/version.ts — defines protocol version 1 (source; added; 1 changed line).

The portable-core rule permits only the shared core, @kilocode/mcp-gateway, and Zod; TypeScript rejects ambient browser and Node globals. The no-client-executors-or-credentials rule blocks transitive server, credential, database, and model-execution imports from browser, native, Quick Chat, and React entrypoints. The checks use dependency-cruiser to resolve aliases and symlinks, scan present entrypoints, and exercise forbidden dependencies through temporary fixtures.

Files
  • packages/agent-harness/tsconfig.json — limits strict checks to ES2022 without ambient platform types; excludes tests and emits no files (source; added; 15 changed lines).
  • packages/agent-harness/vitest.config.ts — runs the shared tests in Node (source; added; 3 changed lines).
  • packages/agent-harness/src/boundaries.test.ts — adds live-source and transitive-import checks, including browser globals and aliased credential imports (test; added; 184 changed lines).

@kilocode/agent-harness-worker adds a private Worker workspace with model clients, Model Context Protocol (MCP), validation, authentication, routing, and storage dependencies. The cloudflareTest setup uses remoteBindings: false and nodejs_compat, with optional Wrangler settings to keep checks local. passWithNoTests: true permits setup checks before any Worker entrypoint or runtime test exists; this change adds no deployment.

Files
  • services/agent-harness/package.json — adds source exports, excludes tests, and registers the shared contract, runtime dependencies, and Worker tools (source; added; 39 changed lines).
  • services/agent-harness/tsconfig.json — enables strict ES2022 checks with Worker/Node types, JSON imports, and generated-binding support (source; added; 15 changed lines).
  • services/agent-harness/vitest.config.ts — sets local compatibility to 2026-06-05, loads optional Wrangler settings, and permits an empty test suite (source; added; 17 changed lines).

web and kilo-app now depend on @kilocode/agent-harness, with dependenciesMeta setting injected: true for mobile React isolation. The web dependency set adds idb, Testing Library, fake-indexeddb, and jest-environment-jsdom for browser storage and component tests. These dependencies prepare host work without adding a client host or changing Quick Chat behavior.

Files
  • apps/mobile/package.json — adds the harness dependency and pnpm injection for the mobile React peer (source; modified; 4 changed lines).
  • apps/web/package.json — adds the harness, idb, @testing-library/dom, @testing-library/jest-dom, @testing-library/react, @testing-library/user-event, fake-indexeddb, and jest-environment-jsdom (source; modified; 8 changed lines).

Continuous integration (CI) now accepts every target branch for pull_request events, while mobile checks retain their path filters. @kilocode/agent-harness changes select web and mobile checks; test:agent-harness-ci runs the setup and import checks before typechecking. push remains limited to main, so stacked pull requests receive checks without expanding push triggers.

Files
  • .github/workflows/ci.yml — removes the target-branch filter, selects web checks for harness changes, and runs the contract command before typechecking (source; modified; 5 changed lines).
  • .github/workflows/kilo-app-ci.yml — removes the pull-request target filter and adds harness paths for push and pull-request checks (source; modified; 3 changed lines).
  • package.json — adds the combined Node contract and Vitest boundary command (source; modified; 1 changed line).
  • scripts/agent-harness-ci.test.mjs — covers workflow contracts, workspace imports, stacked/push/local selection, and Jest component/server fixtures (test; added; 220 changed lines).

pull_request workspace selection now reads pull_request.head.sha and pull_request.base.sha, rather than comparing the checkout with origin/main. Dependency, package, and workspace checks use the target merge base and actual head, excluding unrelated base changes and synthetic merge changes. Invalid pull-request revisions fail explicitly; push and local fallback behavior stays unchanged.

Files
  • scripts/changed-workspaces.sh — passes the target/head revision pair through every change detector and preserves push/local fallbacks (source; modified; 23 changed lines).

testMatch now discovers Quick Chat tests written in TSX without adding unrelated component tests. The TSX transform uses the automatic React runtime and keeps decorator metadata; other TypeScript and JavaScript transforms remain separate. testEnvironment remains node; component tests opt into jsdom instead of changing server-test behavior.

Files
  • apps/web/jest.config.ts — adds scoped TSX discovery and a separate @swc/jest transform while retaining the Node default (source; modified; 21 changed lines).

Tests: 2 added files, 404 added lines — packages/agent-harness/src/boundaries.test.ts (184) and scripts/agent-harness-ci.test.mjs (220).
Generated: 1 modified lockfile — pnpm-lock.yaml (418 changed lines).


Visual Changes

Visual Changes: N/A

Verification

No manual end-to-end (E2E) tests ran. This level changes no user-facing runtime behavior.

Reviewer Notes

Automated checks

  • Recorded verification passed 8 implementation checks and 9 read-only checks.
  • The checks cover CI contracts, import boundaries, both workspace typechecks, and local Worker configuration startup.
  • Scoped lint, formatting, shell syntax, and whitespace checks also passed.
  • Worker verification covers configuration only; this level contains no Worker runtime tests.
  • The read-only verification did not include frozen-lockfile installation or repository-wide checks.

Human steps

No human step is required before or after merge for this foundation level.

  • After merge, before later runtime activation: Provision the scoped Worker/server resources.

Scope

  • Repository: Kilo-Org/cloud.
  • Worktree: /Users/igor/Projects/.worktrees/shared-agent-harness-3bb0.
  • Branch: shared-agent-harness-3bb0; base: origin/main; commit: 4c4cd031b8dca9e119eaa4d15165de3a23b24f1d.
  • Level 1, a1: 17 changed files, 987 insertions, and 28 deletions.
  • File sizes count added and removed lines from the supplied statistics.

Notes

E2E: This level changes no user-facing runtime behavior. Full backend, browser, iOS, and Android verification runs on the completed stack tip.

Stacked PRs — merge bottom to top. Each level shows only its own diff.

Runtime verification (E2E, user advocacy, simplify) runs on the tip PR over every level.
Every level keeps its own checks, its own bot review, and its own threads; each one is answered on its own PR.
Each level is its own deliverable: it builds and passes its own checks alone.
A finding on a level is repaired on that level, then carried upward with stack.sh forward.

  1. shared-agent-harness-3bb0chore(agent-harness): register workspaces and enforce CI boundaries #5632 ← this PR
  2. shared-agent-harness-3bb0-s2feat(agent-harness): define portable domain and snapshots #5637
  3. shared-agent-harness-3bb0-s3feat(agent-harness): define commands tools and permission policy #5639
  4. shared-agent-harness-3bb0-s4feat(agent-harness): share client state and cursor recovery #5643
  5. shared-agent-harness-3bb0-s5feat(agent-harness): persist command intents and execution receipts #5647
  6. shared-agent-harness-3bb0-s6feat(db): add harness ingress grants and retirement fences #5655
  7. shared-agent-harness-3bb0-s7feat(agent-harness): deliver legacy history and project durable text #5659
  8. shared-agent-harness-3bb0-s8feat(agent-harness): authorize durable grants and registered clients #5662
  9. shared-agent-harness-3bb0-s9feat(agent-harness): fence retirement and retry payload cleanup #5667
  10. shared-agent-harness-3bb0-s10feat(agent-harness): persist authoritative state in SQLite #5675
  11. shared-agent-harness-3bb0-s11feat(agent-harness): admit durable runs and revisioned commands #5678
  12. shared-agent-harness-3bb0-s12feat(agent-harness): recover queued runs and stream checkpointed steps #5688
  13. shared-agent-harness-3bb0-s13feat(agent-harness): resolve interactions and dispatch tools sequentially #5693
  14. shared-agent-harness-3bb0-s14feat(agent-harness): fence designated client tool execution #5697
  15. shared-agent-harness-3bb0-s15feat(agent-harness): synchronize durable snapshots and legacy history #5701
  16. shared-agent-harness-3bb0-s16feat(agent-harness): reuse authorized invitations with durable replay #5704
  17. shared-agent-harness-3bb0-s17feat(integrations): bound repository transport for harness reads #5710
  18. shared-agent-harness-3bb0-s18feat(integrations): expose bounded authorized repository reads #5714
  19. shared-agent-harness-3bb0-s19feat(agent-harness): expose named authorized resource reads #5718
  20. shared-agent-harness-3bb0-s20feat(sessions): bound history transport for harness reads #5724
  21. shared-agent-harness-3bb0-s21feat(agent-harness): read scoped Cloud Agent context and progress #5726
  22. shared-agent-harness-3bb0-s22fix(agent-harness): preserve ordered Cloud Agent dispatch identity #5731
  23. shared-agent-harness-3bb0-s23feat(agent-harness): hand coding work to authorized Cloud Agent sessions #5733
  24. shared-agent-harness-3bb0-s24feat(agent-harness): authorize scoped MCP gateway connections #5737
  25. shared-agent-harness-3bb0-s25feat(agent-harness): bound MCP gateway transport in the Worker #5740
  26. shared-agent-harness-3bb0-s26feat(agent-harness): execute validated remote MCP tools #5743
  27. shared-agent-harness-3bb0-s27refactor(exa): share provider dispatch and usage recording #5746
  28. shared-agent-harness-3bb0-s28feat(agent-harness): authorize bounded web provider requests #5747
  29. shared-agent-harness-3bb0-s29feat(agent-harness): normalize web sources and preserve citations #5749
  30. shared-agent-harness-3bb0-s30feat(agent-harness): define closed internal operation contracts #5753
  31. shared-agent-harness-3bb0-s31feat(agent-harness): authorize internal maintenance operations #5754
  32. shared-agent-harness-3bb0-s32feat(agent-harness): authorize named Kilo operation dispatch #5755
  33. shared-agent-harness-3bb0-s33feat(agent-harness): authorize internal provider operations #5757
  34. shared-agent-harness-3bb0-s34feat(agent-harness): secure the internal operations endpoint #5758
  35. shared-agent-harness-3bb0-s35feat(agent-harness): bound and sanitize model streams #5767
  36. shared-agent-harness-3bb0-s36feat(agent-harness): secure billed model inference #5776
  37. shared-agent-harness-3bb0-s37test(agent-harness): cover model gateway security boundaries #5777 (tip)

@iscekic iscekic self-assigned this Aug 28, 2026
@kilo-code-bot

kilo-code-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Reviewed the incremental Node URL import in the agent-harness Worker Vitest config; no issues found.

Files Reviewed (1 files)
  • services/agent-harness/vitest.config.ts
Previous Review Summaries (3 snapshots, latest commit 9940937)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 9940937)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • pnpm-lock.yaml
  • pnpm-workspace.yaml

Previous review (commit a57f7e9)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • apps/mobile/package.json
  • pnpm-lock.yaml
  • pnpm-workspace.yaml
  • scripts/agent-harness-ci.test.mjs

Previous review (commit 4c4cd03)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

Unused @kilocode/agent-harness on mobile will fail the knip check:unused job this PR now triggers.

Overview

Severity Count
CRITICAL 1
WARNING 0
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

CRITICAL

File Line Issue
apps/mobile/package.json 37 Unused @kilocode/agent-harness will fail mobile knip check:unused
Files Reviewed (17 files)
  • .github/workflows/ci.yml
  • .github/workflows/kilo-app-ci.yml
  • apps/mobile/package.json - 1 issue
  • apps/web/jest.config.ts
  • apps/web/package.json
  • package.json
  • packages/agent-harness/package.json
  • packages/agent-harness/src/boundaries.test.ts
  • packages/agent-harness/src/version.ts
  • packages/agent-harness/tsconfig.json
  • packages/agent-harness/vitest.config.ts
  • pnpm-lock.yaml
  • scripts/agent-harness-ci.test.mjs
  • scripts/changed-workspaces.sh
  • services/agent-harness/package.json
  • services/agent-harness/tsconfig.json
  • services/agent-harness/vitest.config.ts

Reviewed by grok-4.6 · Input: 109.1K · Output: 5K · Cached: 248.6K

Review guidance: REVIEW.md from base branch main

This was referenced Aug 28, 2026
Keep browser declarations out of Vitest's optional Worker type surface. Defer the mobile harness dependency until its first real consumer.
Rebind the harness Worker to main's Expo peer snapshot and preserve closed Storybook peer references.
@iscekic

iscekic commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Closing: the owner stopped this workflow section. The branch is retained.

@iscekic iscekic closed this Aug 31, 2026
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