Skip to content

refactor: make @codeworksh/schema the shared home for contracts - #184

Merged
sanchitrk merged 3 commits into
canaryfrom
claude/local-workspace-single-user-483b0e
Nov 29, 2026
Merged

sanchitrk merged 3 commits into
canaryfrom
claude/local-workspace-single-user-483b0e

Conversation

@sanchitrk

@sanchitrk sanchitrk commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

packages/schema becomes a published package that holds every schema more than one package speaks, so each is declared once. Along the way this removes three leftovers that needed no compatibility, since nothing is in production yet.

Schema

  • @codeworksh/schema is published (0.1.0) with one subpath per module and no root entry. Importing a light module no longer loads Relay's HTTP API.
  • The shapes packages/plugin held only for the harness move in: ids, projects, repos, spaces, location info and errors, the event core, sandbox instances and errors, and the shared helpers. Settings and the aikit adapters stay in plugin, because schema stays browser-safe and free of aikit.
  • The host's RPC contract moves in as @codeworksh/schema/host (with its wire record schemas split into @codeworksh/schema/host/records), alongside the harness error classes its error unions use. The server implements it and the apps import it. The hand-kept copy in apps/widget/src/codework.ts is gone; that file re-exports @codeworksh/schema/host/records, exports type { Api } from @codeworksh/schema/host (keeping server RPCs and error classes out of the apps/web bundle), and keeps its two helpers.
  • The dependency direction is schema ← plugin ← harness. The binary shares schema with loaded plugins, as it does effect and plugin.

The server's wire format is unchanged: 62 RPCs with the same payloads, results and errors. The apps now decode with the real contract, so they reject replies from a server built against the older one.

Relay

  • Columns that say which account a row belongs to are account_id: workspace.created_by and machine.owner_id are renamed, and the wire fields follow (accountId, account).
  • member.role is plain text; the allowed values live in the schema, and machine-management authorization checks fail closed against an owner/admin allowlist.
  • A link in <home>/machine.json stores account instead of owner.
  • One init migration.

Apps

  • The placeholder organization scope is removed from app.db, the app contract, the mirror, reads, ordering, tracking and the widgets. It held one constant value.
  • app.db has one init migration.

Breaking

  • Existing app.db files and Relay databases must be recreated.
  • Existing <home>/machine.json files with "owner" fail Machine.read() and must be removed (or migrated to "account") before starting serve or linking the machine again.
  • The desktop app and the codework server must be updated together.
  • @codeworksh/plugin drops the ids, project, repo, space, sandbox/instance, and sandbox/errors subpaths, location error classes from ./location, and schema helpers from ./schema.
  • @codeworksh/schema is new on npm (0.0.0 placeholder published and GitHub Actions trusted publisher configured for publish.yml).

Testing

  • vp run verify: passes.
  • packages/harness, non-live: 85 files, 630 tests pass.
  • packages/codework, non-live, with the bundle and the single binary: 159 pass. recovery.test.ts ("a reply killed mid-stream…") timed out once at 90s in the full run and passed twice when run alone.
  • apps/server, non-live: 52 pass. infra/relay against real Postgres: 9 pass.
  • Typechecks for widget, contract, server, web, desktop, relay, and extras/* pass. A release dry run orders aikit, schema, plugin, harness, cli.
  • apps/web production build: verified Host.Api and server error classes are excluded from the browser bundle.
  • Live suites against real models: on Anthropic (claude-sonnet-5-5) harness 13 pass and codework 1 pass; on OpenAI (gpt-5.6-luna) harness 13 pass and codework 3 pass. One GitHub Copilot case in prompt.changes.live.test.ts made three requests where it expects two; the file passed when run again alone. In sea.test.ts, the offline plugin-sharing case (including @codeworksh/schema/{common,ids} with no node on PATH) and OpenAI (gpt-5.6-luna) live case pass; OpenRouter (meta/muse-spark-1.3-contributor) returned no tool calls.
  • Real desktop app on a fresh home and a fresh Relay database: signed in, linked the machine (the link is stored under account, and Relay's row has the matching account_id), added a project, ran sessions with real tool calls on GPT-5.6 Luna and Claude Sonnet 5.5, created a thread group by hand in Threads and assigned a thread (verified in app.db), and verified the sidebar, Threads, and Settings → Machines pages render with zero console errors.
  • OrbStack machine suites in apps/server, on four machines: sync (12/12), recovery, usage (6/6) and metrics.simulation pass, 31 cases (with usage and sync re-run after review fixes). The four sync.machines artifacts that lost their organization_id lines pass unchanged.
  • Those suites needed a fixture fix that is in this PR. Four sync cases and one metrics case failed on canary too: replacing a machine's store also dropped its machine.json, so the app refused the machine's new key and never synced it again. The fixtures keep devices.json and machine.json now.
  • Still failing, on canary too: daemon.machines.live.test.ts, "a host space on the server's machine". After a restart a late subscriber gets the space's change status replayed as well as server.connected, and the artifact from before expects only the latter. Left as it is: whether the replay is intended is a separate decision.
  • Not run: the Daytona daemon case (no key).
  • test:sandbox:package in harness fails at its first check for a reason that predates this change and was left alone.

Claude Fable 5.2, with Claude Opus 5.5 subagents, in Claude Code (review fixes and follow-up verification with Antigravity).

🤖 Generated with Claude Code


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

sanchitrk and others added 3 commits November 29, 2026 18:22
packages/schema becomes a published package with one subpath per module
and holds every schema more than one package speaks: ids, projects,
spaces, locations, the event core, sandbox instances, and the host's RPC
contract with the harness error classes in its error unions. plugin and
harness import them from there, and the apps import the one contract, so
the hand-kept copy in apps/widget is gone.

Alongside it, three cleanups that needed no compatibility, since nothing
is in production yet:

- apps: remove the placeholder organization scope from app.db, the app
  contract, the mirror and the widgets.
- relay: columns that say which account a row belongs to are account_id
  (workspace.created_by, machine.owner_id), the wire fields follow, and
  member.role is plain text. A link in machine.json stores account.
- apps/server and relay each have a single init migration.

Existing app.db files and Relay databases must be recreated, a linked
machine.json must be linked again, and the desktop app and the server
must be updated together.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…s store

The suites made a new store by wiping or moving the machine's home, which
also dropped machine.json. Since pairing checks the key a machine paired
with, the app refused the machine afterwards and never synced it again, so
the store-replacement cases timed out. They keep devices.json and
machine.json now.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…and apps

- Export Info as a value from @codeworksh/plugin/location so packed .d.mts emits a value export, and reuse ThinkingLevel from @codeworksh/schema/model in @codeworksh/plugin/settings.
- Split host wire records into @codeworksh/schema/host/records and re-export only records (plus type-only Api) from apps/widget/src/codework.ts, keeping Host.Api and server error classes out of apps/web.
- Decode unvalidated AbsolutePath, SessionID, and ThreadID strings via Effect schemas instead of throwing synchronous .make() defects in apps/server and apps/web.
- Make Relay and Settings machine-management role checks fail closed (owner/admin allowlist) after removing the DB CHECK constraint.
- Verify @codeworksh/schema/{common,ids} sharing in sea.test.ts, add @codeworksh/schema peerDependencies to extras/*, and document @codeworksh/schema/host/records in packages/schema/README.md.
@sanchitrk
sanchitrk merged commit 336229f into canary Nov 29, 2026
3 checks passed
@sanchitrk
sanchitrk deleted the claude/local-workspace-single-user-483b0e branch November 29, 2026 19:10
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