Repository navigation
chore(harness): delete the TypeScript CLI harnesses and un-blind knip on the package - #5573
Merged
Merged
Conversation
…harnesses `assertHarnessRunsInCluster` throws for claude-code/codex at the dispatch gate, and `dispatchRunAndWait` throws again on any non-decopilot id — so the factories the barrel registered could never be reached by a lookup. Local CLI runs happen in the Tauri app's Rust harness crate; cloud-CLI is unimplemented. Also removes `buildSandboxDaemon()` from the server bundler: it built packages/sandbox's daemon bundle + typegen tarball on every API build for host/runner.ts's text-import, and that file no longer exists (#5570). The sandbox image workflow runs its own `bun run --cwd=packages/sandbox build`, so the image is unaffected.
… test Asserting a file's source does not contain a symbol tests the deletion, not the behavior. The registry lookup is already covered by the gate's own tests.
… hosts them #5575 deleted the TS sandbox daemon, which was the last runtime that registered `claudeCodeHarnessFactory`/`codexHarnessFactory`; the preceding commit dropped the cluster's unreachable registration. That left the whole TS CLI harness implementation with zero production consumers — the live one is Rust (`apps/native/crates/harness`), which is a port, not a consumer. Deleted: packages/harness/src/{codex,claude-code/index,resolve-executable, model/index}, cli-session-error, cli-stream-metadata, the ./claude-code and ./codex export subpaths, and the ai-sdk-provider-{claude-code,codex-cli} deps. Kept: claude-code/model/agent-tiers.ts + chat-tier.ts (apps/web and apps/api import `resolveAgentTier` to build the model picker), and cli-harness.ts's `cliProviderName` (the read side of CLI session resume). Knip could not see any of this: packages/harness's exports map has a "./*" glob, so every src file looks like a public entrypoint. - cli-import-boundary.test.ts deleted: it read claude-code/index.ts and codex/index.ts off disk, so it fails ENOENT once they are gone. - cli-harness.test.ts covered only `isCliHarness`, which was dead. Repointed to `cliProviderName` — the surviving export, and a cross-language contract with the Rust crate that had no test at all. - cli-message-prep.ts lost `prepCliMessages` (CLI-only) and kept `extractUserText` (decopilot). Renamed to extract-user-text.ts so the filename stops describing code that is gone.
viktormarinho
force-pushed
the
chore/drop-dead-cli-harness-registration
branch
from
August 3, 2026 00:59
1f90718 to
e83b7c9
Compare
The overview still advertised Claude Code and Codex harnesses, a codex usage example, and "portable between the API and sandbox daemon" as the boundary rationale — all three are gone. Restates the real one: apps/web and packages/sandbox are lint-barred from apps/api/src, so the contracts the three share have to live outside the API.
packages/harness's exports ended in "./*": ["./src/*.ts", "./src/*/index.ts"], so every file under src/ looked like a public entry point and knip could never report anything here as unused. That is how ~2k lines of dead CLI harness code stayed invisible until it was grepped by hand. Replaces the glob with the 56 subpaths actually imported (plus "."), generated from the real import specifiers across apps/ and packages/ and verified to resolve. No consumer changes: bun run check passes in all 15 workspaces. Knip now reports on this package, and immediately found two things the glob was hiding: - no-background-tasks-prompt.ts — a system-prompt fragment whose own doc says "shared across CLI harnesses (claude-code, codex)"; orphaned when those were deleted. Removed. - THOUGHT_SIGNATURE_SEPARATOR — used only inside its own module. Narrowed to module-private. No guard test: a missing entry is already a compile error (TS2307) on bun run check. Documented in the README, since that message reads as "file missing" when the file is merely unexported.
decocms Bot
pushed a commit
that referenced
this pull request
Aug 3, 2026
PR: #5573 chore(harness): delete the TypeScript CLI harnesses and un-blind knip on the package Bump type: patch - decocms (apps/api/package.json): 4.160.3 -> 4.160.4 - @decocms/native (apps/native/package.json): 4.160.3 -> 4.160.4 - @decocms/harness (packages/harness/package.json): 2.8.4 -> 2.8.5 Deploy-Scope: server
viktormarinho
added a commit
that referenced
this pull request
Aug 3, 2026
…arness registry Final step of the harness-package teardown (#5573 deleted the dead TS CLI harnesses; #5577 moved the wire contracts to @decocms/shared/harness). After those, the package was 9.5k lines consumed by apps/api alone — its stated reason to exist (portability into the desktop daemon's bundle) died with the link daemon (#5570) and the TS sandbox daemon (#5575). The move: - packages/harness/src → apps/api/src/harnesses/lib (git mv, history kept). 58 api files rewritten from "@decocms/harness/X" to "@/harnesses/lib/X". All the lib's deps were already in apps/api's manifest; the workspace package, its README, tsconfig and dependency edges are gone. - The leaf discipline survives as a directory rule: ban-cross-tree-imports now applies its harness clauses (no @/ imports, no @/core/studio-context, no @aws-sdk/*) to apps/api/src/harnesses/lib/, and no-cross-tree.test.ts moved with the tree and still guards it. The engine stays a leaf; only the package wrapper is gone. The registry collapse (spec §5.4, executed at last): - InProcessSandboxClient absorbs localDispatch and hard-wires decopilotHarnessFactory — the registry it consulted was a Map with one entry, populated by an import side effect. registry.ts, localDispatch, the orphaned lib barrel and their registration tests are deleted; the client's tests now assert the real factory's contract (eager CLI guard, lazy stream) instead of stubbing a seam. - apps/api/src/harnesses/index.ts keeps one side effect: registering the cluster environment builder the factory requires. Fallout knip caught once the package boundary stopped hiding it: - buildRepoEnvironmentPrompt: dead (nothing builds that prompt block). Deleted. - CHAT_MODES: only its derived type is consumed. Narrowed to module-private. DBOS workflow-source snapshot re-baselined (import-specifier text is hashed; apps/api/scripts/update-workflow-source-snapshot.ts, 8 hashes). Infra: sandbox-daemon.yml change filter, release-changes test fixtures, root README workspace table, bundle-server-script comment.
viktormarinho
added a commit
that referenced
this pull request
Aug 3, 2026
…arness registry (#5578) Final step of the harness-package teardown (#5573 deleted the dead TS CLI harnesses; #5577 moved the wire contracts to @decocms/shared/harness). After those, the package was 9.5k lines consumed by apps/api alone — its stated reason to exist (portability into the desktop daemon's bundle) died with the link daemon (#5570) and the TS sandbox daemon (#5575). The move: - packages/harness/src → apps/api/src/harnesses/lib (git mv, history kept). 58 api files rewritten from "@decocms/harness/X" to "@/harnesses/lib/X". All the lib's deps were already in apps/api's manifest; the workspace package, its README, tsconfig and dependency edges are gone. - The leaf discipline survives as a directory rule: ban-cross-tree-imports now applies its harness clauses (no @/ imports, no @/core/studio-context, no @aws-sdk/*) to apps/api/src/harnesses/lib/, and no-cross-tree.test.ts moved with the tree and still guards it. The engine stays a leaf; only the package wrapper is gone. The registry collapse (spec §5.4, executed at last): - InProcessSandboxClient absorbs localDispatch and hard-wires decopilotHarnessFactory — the registry it consulted was a Map with one entry, populated by an import side effect. registry.ts, localDispatch, the orphaned lib barrel and their registration tests are deleted; the client's tests now assert the real factory's contract (eager CLI guard, lazy stream) instead of stubbing a seam. - apps/api/src/harnesses/index.ts keeps one side effect: registering the cluster environment builder the factory requires. Fallout knip caught once the package boundary stopped hiding it: - buildRepoEnvironmentPrompt: dead (nothing builds that prompt block). Deleted. - CHAT_MODES: only its derived type is consumed. Narrowed to module-private. DBOS workflow-source snapshot re-baselined (import-specifier text is hashed; apps/api/scripts/update-workflow-source-snapshot.ts, 8 hashes). Infra: sandbox-daemon.yml change filter, release-changes test fixtures, root README workspace table, bundle-server-script comment.
This was referenced Aug 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #5570 (desktop link removal) and #5575 (TypeScript daemon removal). One causal chain, in five commits — each step is what made the next one visible.
1. The cluster registered two harness factories nothing could look up
apps/api/src/harnesses/index.tsregisteredclaudeCodeHarnessFactoryandcodexHarnessFactory. Both were unreachable — the cluster dispatch path guards them twice, before any registry lookup:assertHarnessRunsInCluster(dispatch-queue/thread-gate-workflow.ts) throws forclaude-code/codexat the gate.dispatchRunAndWaitthrows again on any non-decopilotid before constructingInProcessSandboxClient.localDispatch→getHarnessFactoryis only reachable past both, so the registration could only ever produce a factory nobody can call.2. …which left the whole TypeScript CLI harness implementation dead
#5575 deleted the TS sandbox daemon — the last runtime that registered those two factories. With the cluster registration gone too,
packages/harness/src/{claude-code,codex}had zero production consumers.The live CLI implementation is Rust (
apps/native/crates/harness/), and it is a port of this code, not a consumer — a TypeScript factory interface does nothing for it.Deleted (~2,050 lines): the
codex/subtree,claude-code/{index,resolve-executable,model/index},cli-session-error,cli-stream-metadata, the./claude-code+./codexexport subpaths, and theai-sdk-provider-claude-code/ai-sdk-provider-codex-clidependencies.Kept:
claude-code/model/agent-tiers.ts+chat-tier.ts—apps/web/src/components/chat/use-agent-mode.tsandapps/api/src/api/routes/decopilot/routes.tsimportresolveAgentTierto build the model picker.cli-harness.ts'scliProviderName— the read side of CLI session resume (resolveCliSessionRef/computeCliDelta) still needs it.HarnessIdis not touched: it stays a 3-value union. It is persisted inthreads.harness_id, drives the chat agent picker, and is the wire vocabulary the Rust crate speaks. That is a domain enum and it is legitimate — what died is the TS implementation behind two of its values.3. …which knip could not see, because the exports map was a wildcard
packages/harness/package.json's exports ended in"./*": ["./src/*.ts", "./src/*/index.ts"]. Every file undersrc/therefore looked like a public entry point, so knip could never report anything in this package as unused — it returned exit 0 both before and after deleting 2k lines. The orphans above had to be found by grepping module reachability by hand.Replaced the glob with the 56 subpaths actually imported (plus
"."), generated from the real import specifiers acrossapps/andpackages/, each verified to resolve to a file on disk. No consumer changes.Knip then immediately found two more things the glob had been hiding:
src/no-background-tasks-prompt.ts— deleted. Its own doc says "Shared across CLI harnesses (claude-code, codex)"; orphaned by step 2, zero remaining references.THOUGHT_SIGNATURE_SEPARATOR— narrowed to module-private. Used only insidedecopilot/thought-signature.ts.Knip is now exit 0 on a map that can actually go stale, which is the point.
Testing
bun testoverpackages/harness apps/api/src/{harnesses,dispatch-queue,api/routes/decopilot}: 1017 pass / 16 fail on this branch, and the same 16 onorigin/main—diffof the two sorted failure lists is empty. They are the DB-dependent tests (no local Postgres).bun test packages/harnessalone: 341 pass, 0 fail.bun run checkclean across all 15 workspaces — which is also the proof that nothing reachable before is unreachable now.bun run lint: 14 warnings / 0 errors, identical to themainbaseline (diffed via stash).knipexit 0..ts/.tsx(.js,.mjs,.cjs,.json, dynamicimport(),require): none.Tests changed, not just deleted
cli-import-boundary.test.tsdeleted, because it breaks: it readclaude-code/index.tsandcodex/index.tsoff disk and fails ENOENT once they are gone. (It was also a source-text assertion, which is not a test.)cli-harness.test.tsrepointed: it only coveredisCliHarness, which was dead. It now coverscliProviderName— the surviving export, and a cross-language contract with the Rust crate that previously had no test at all.cli-message-prep.tslostprepCliMessages(CLI-only, self-tested) and keptextractUserText(used by decopilot). Renamed toextract-user-text.tsso the filename stops describing code that no longer exists.No guard test for the exports map, deliberately
Forgetting an entry for a newly shared module already fails loudly at
bun run check— verified by probing with a real unexported subpath:The compiler is the check. It is documented in the README, because that message reads as "the file is missing" when the file is merely unexported.
README
Corrected, because these deletions made it wrong. It still advertised Claude Code and Codex harnesses, a
codexHarnessFactoryusage example, and "portable between the API and sandbox daemon" as the boundary rationale. All three are gone.What this leaves, for the record
Exactly one harness now runs in Kubernetes:
decopilot, in the API worker. Not even in the sandbox pod — the Go daemon dispatches harnesses through aHARNESS_RUNNER_CMDsubprocess, and that env is set nowhere in the Dockerfile or the helm chart, soPOST /_sandbox/dispatchalways answersunknown_harness.To reach that single implementation the cluster still goes through five hops:
InProcessSandboxClient(1 impl ofSandboxClient) →localDispatch→getHarnessFactory(aMapwith one entry, populated by import side-effect) →HarnessFactory.create(1 impl) →Harness.stream(1 impl).And
packages/harnessis now 10.4k lines of whichsrc/decopilot/is 73%, imported byapps/apionly.apps/web(5 subpaths) andpackages/sandbox(3) consume contracts, not the agent loop. The package's stated rationale — portability into the desktop daemon's bundle — died with #5570 and #5575; what justifies the boundary today is thatapps/webandpackages/sandboxare lint-barred from importingapps/api/src.Both of those are design changes rather than dead-code deletions, so neither is in this PR.