Repository navigation
refactor(shared): move the harness wire contracts to @decocms/shared/harness - #5577
Merged
Merged
Conversation
…harness apps/web (19 files) and packages/sandbox (3) imported 7 subpaths of @decocms/harness — all of them contracts (HarnessId, ModelsConfig, ChatMode, HarnessStreamInput, the run-stream codec, offload envelope, skill front-matter parser, todo-write schema, storage-uri helpers, agent tiers), none of them the agent loop. That dependency is what kept a 10.4k-line package looking shared when 92% of it is consumed by apps/api alone. Moves those surfaces (~820 LOC + their tests, via git mv) into packages/shared/src/harness/ — the package CLAUDE.md already defines as 'isomorphic contracts, browser-safe'. They fit: no node: builtins, deps only ai + zod, both already in packages/shared. - types.ts is split: domain/wire types move; the host-side execution contracts (Harness, HarnessContext, HarnessFactory — API-only, and the otel-typed part) stay in @decocms/harness. - chat-tier.ts's ChatTier existed only to mirror @decocms/shared/organization/schema:ChatTierSchema without a cross-package reach. Living in shared, it now derives from the schema it mirrored. - @decocms/harness keeps re-export shims at the old paths so the API and harness internals are untouched here; the shims go when decopilot/ folds into apps/api. - apps/web and packages/sandbox drop the @decocms/harness dependency entirely: the package is now consumed by apps/api only.
viktormarinho
force-pushed
the
refactor/harness-contracts-to-shared
branch
from
August 3, 2026 01:48
c1904b6 to
9ba142e
Compare
viktormarinho
enabled auto-merge (squash)
August 3, 2026 01:50
decocms Bot
pushed a commit
that referenced
this pull request
Aug 3, 2026
PR: #5577 refactor(shared): move the harness wire contracts to @decocms/shared/harness Bump type: patch - decocms (apps/api/package.json): 4.160.4 -> 4.160.5 - @decocms/native (apps/native/package.json): 4.160.4 -> 4.160.5 - @decocms/harness (packages/harness/package.json): 2.8.5 -> 2.8.6 - @decocms/sandbox (packages/sandbox/package.json): 1.35.4 -> 1.35.5 - @decocms/shared (packages/shared/package.json): 0.13.3 -> 0.13.4 - deploy/helm/sandbox-env (chart 0.10.4) (deploy/helm/sandbox-env/values.yaml deploy/helm/sandbox-env/Chart.yaml): image.tag/appVersion -> 1.35.5 Deploy-Scope: web
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 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.
Step 2 of the
packages/harnessteardown; #5573 (merged) was step 1. Rebased onto it — clean, no conflicts, as the shim design intended.Post-rebase pruning (composing with #5573's enumerated exports map): the
offload-messagesshim came out fully orphaned — nothing consumed it via subpath or barrel — so shim + barrel re-exports + exports entry are deleted rather than kept. And knip (now able to see the package, per #5573) immediately flagged thechat-tier.tsshim as unused: its last importer died in #5573 andagent-tiersderivesChatTierfrom the schema now. Deleted too. Two shims fewer than originally described below.Why
apps/web(19 files) andpackages/sandbox(3 files) imported 7 subpaths of@decocms/harness. Every one of them is a contract —HarnessId,ModelsConfig,ChatMode,HarnessStreamInput, the run-stream codec, the offload envelope, the skill front-matter parser, the todo-write schema, storage-uri helpers, agent tiers. None of them is the agent loop.That dependency is what made a 10.4k-line package look shared when 92% of it is consumed by
apps/apialone. After this PR,@decocms/harnessis API-only — which is what makes the endgame (foldingdecopilot/intoapps/api/srcand deleting the package) a mechanical follow-up instead of a design question.What moved
~820 LOC + their co-located tests, via
git mv, intopackages/shared/src/harness/— the package CLAUDE.md already defines as "isomorphic contracts, browser-safe SDK utilities". They qualify: nonode:builtins, dependencies onlyai+zod, both already inpackages/shared.@decocms/harness/…@decocms/shared/harness/…types(domain/wire part)typesrun-stream-codecrun-stream-codecoffload-messagesoffload-messagesskills/skill-mdskill-mddecopilot/built-in-tools/todo-writetodo-writedecopilot/studio-storage-uristudio-storage-uriclaude-code/model/agent-tiersagent-tiersThree judgment calls
1.
types.tsis split, not moved whole. The domain/wire types move; the host-side execution contracts (Harness,HarnessContext,HarnessFactory) stay in@decocms/harness. Only the API uses them,HarnessContextis typed against@opentelemetry/api(whichpackages/shareddoesn't and shouldn't have), and all three are slated to die when the one-entry registry collapses in the follow-up.2.
@decocms/harnesskeeps re-export shims at the old paths. The API and harness internals import these modules from ~50 places; repointing them here would drag half ofapps/apiinto this diff and conflict with #5573. The shims are 3 lines each and are deleted by the follow-up that foldsdecopilot/intoapps/api. This PR's blast radius is: moved files + the 22 web/sandbox import sites + two package.jsons.3.
ChatTierstops being a mirror.chat-tier.ts's doc said it mirrored@decocms/shared/organization/schema:ChatTierSchema"so the harness tree carries no@/*reach". Living inpackages/shared, the reach exists natively — the type now derives from the schema it used to mirror. One duplication deleted.The visible result
apps/web/package.jsonandpackages/sandbox/package.jsondrop@decocms/harnessentirely.Testing
bun run checkclean across all 15 workspaces — which is also the proof that every consumer resolved after the move.bun testover the moved tests + both consumers' suites (packages/shared/src/harness,packages/harness,packages/sandbox/dispatch, the touched web tests): 460 pass, 0 fail.bun run lint: 14 warnings / 0 errors, identical tomainbaseline (kebab-case plugin covers the newpackages/sharedfiles).knipexit 0.@decocms/harnessreferences inapps/web+packages/sandbox: zero (three stale doc comments updated).Follow-up (not here)
With web/sandbox off the package: move
decopilot/+ the top-level utilities intoapps/api/src/, delete the shims, delete@decocms/harness, and collapse the one-entry registry (InProcessSandboxClient→localDispatch→getHarnessFactory→factory.create().stream()becomes a function call). That is ~9.5k lines ofgit mvand import rewrites — mechanical after this, but a conflict bomb for open decopilot PRs, so it wants its own window.