Repository navigation
refactor(api): fold @decocms/harness into apps/api and collapse the harness registry - #5578
Merged
Merged
Conversation
…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
force-pushed
the
refactor/fold-harness-into-api
branch
from
August 3, 2026 02:16
174c4ef to
e6fec02
Compare
decocms Bot
pushed a commit
that referenced
this pull request
Aug 3, 2026
PR: #5578 refactor(api): fold @decocms/harness into apps/api and collapse the harness registry Bump type: patch - decocms (apps/api/package.json): 4.160.5 -> 4.160.6 - @decocms/native (apps/native/package.json): 4.160.5 -> 4.160.6 - @decocms/sandbox (packages/sandbox/package.json): 1.35.5 -> 1.35.6 - @decocms/shared (packages/shared/package.json): 0.13.4 -> 0.13.5 - deploy/helm/sandbox-env (chart 0.10.5) (deploy/helm/sandbox-env/values.yaml deploy/helm/sandbox-env/Chart.yaml): image.tag/appVersion -> 1.35.6 Deploy-Scope: server
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.
Final step of the
packages/harnessteardown. #5573 deleted the dead TS CLI harnesses; #5577 moved the wire contracts to@decocms/shared/harness; this deletes the package.Why the package had to go
After the previous two steps it was 9.5k lines consumed by
apps/apialone — 49 of its 56 import subpaths had no consumer outside the API. Its stated reason to exist ("portable into the desktop daemon's bundle", per its owntypes.ts) died with the link daemon (#5570) and the TS sandbox daemon (#5575). What remained wasapps/apiimporting its own agent loop through a package boundary, at the cost of a 56-entry exports map and a knip blind spot.The move (mechanical bulk of the diff)
packages/harness/src→apps/api/src/harnesses/libviagit mv— history preserved, internal relative imports untouched.apps/apifiles rewritten from"@decocms/harness/X"to"@/harnesses/lib/X".apps/api's manifest (the six missing fromdependenciesare indevDependenciesbecause the server bundle inlines them). Nothing added.bun run check:readmesnow validates 14 workspaces.The leaf discipline survives the package's death, as a directory rule.
plugins/ban-cross-tree-imports.jsnow applies its harness clauses — no@/imports, no@/core/studio-context(flatHarnessDeps, never the recursive context, spec §4.2), no@aws-sdk/*— toapps/api/src/harnesses/lib/, andno-cross-tree.test.tsmoved with the tree and still scans it. Verified: the lib has zero@/imports after the rewrite. The engine stays a leaf; only the wrapper is gone.The registry collapse (spec §5.4, executed at last)
in-process-sandbox-client.ts's own header said it: "localDispatchis then folded fully into this client (§5.4)". Done:InProcessSandboxClient.dispatchhard-wiresdecopilotHarnessFactory— the registry it consulted was aMapwith one entry, populated by an import side effect, andlocalDispatchhad exactly one caller.registry.ts,local-dispatch.ts, the orphaned lib barrel (lib/index.ts— nothing imported it), and their registration tests are deleted.dispatchthrows eagerly forclaude-code/codex, same posture asassertHarnessRunsInClusterat the gate.apps/api/src/harnesses/index.tskeeps its one load-bearing side effect: registering the cluster environment builder the factory requires (stream()throws without it — same coupling as before, now documented as the reason the barrel exists).dispatch("decopilot")returns a lazy stream (create()+stream()do no eager work — nothing executes until first pull). No mocks, per TESTING.md.What knip caught once the boundary stopped hiding it
buildRepoEnvironmentPrompt— deleted. Nothing in the repo builds the<repo-environment>prompt block; only a stale comment referenced it.CHAT_MODES— narrowed to module-private. Only its derivedChatModetype is consumed.Testing
main, and it's the known one:bun testoverapps/api/src plugins scriptsfails 199 on this branch vs 198 baseline (same scope +packages/harnessonorigin/main, sorted lists diffed) — the one new failure was the DBOS workflow-source snapshot guard, because import-specifier text is hashed. Re-baselined viaapps/api/scripts/update-workflow-source-snapshot.ts(8 hashes), now green. The 198 are the pre-existing no-local-Postgres failures, byte-identical.bun run checkclean across all 14 workspaces.bun run lintidentical to baseline.knipexit 0.@decocms/harnessmentions in the repo: 3, all deliberate — two "the former @decocms/harness" historical notes, one lint-test fixture that needs an unlisted@decocms/*name (a deleted package is now guaranteed unlisted).Rebase note (not a breaking change — private workspace package, nothing external consumed it)
Open PRs importing
@decocms/harnessrebase onto@/harnesses/lib/*(api) or@decocms/shared/harness/*(contracts).After this PR
The five-hop dispatch chain is two:
InProcessSandboxClient→factory.create(ctx).stream(input). One harness, one host, one package fewer, and knip sees all of it.