Repository navigation
refactor: make @codeworksh/schema the shared home for contracts - #184
Merged
Merged
Conversation
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.
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.
packages/schemabecomes 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/schemais published (0.1.0) with one subpath per module and no root entry. Importing a light module no longer loads Relay's HTTP API.packages/pluginheld 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 inplugin, becauseschemastays browser-safe and free of aikit.@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 inapps/widget/src/codework.tsis gone; that file re-exports@codeworksh/schema/host/records, exportstype { Api }from@codeworksh/schema/host(keeping server RPCs and error classes out of theapps/webbundle), and keeps its two helpers.schema←plugin←harness. The binary sharesschemawith loaded plugins, as it doeseffectandplugin.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
account_id:workspace.created_byandmachine.owner_idare renamed, and the wire fields follow (accountId,account).member.roleis plain text; the allowed values live in the schema, and machine-management authorization checks fail closed against anowner/adminallowlist.<home>/machine.jsonstoresaccountinstead ofowner.initmigration.Apps
organizationscope is removed fromapp.db, the app contract, the mirror, reads, ordering, tracking and the widgets. It held one constant value.app.dbhas oneinitmigration.Breaking
app.dbfiles and Relay databases must be recreated.<home>/machine.jsonfiles with"owner"failMachine.read()and must be removed (or migrated to"account") before startingserveor linking the machine again.codeworkserver must be updated together.@codeworksh/plugindrops theids,project,repo,space,sandbox/instance, andsandbox/errorssubpaths, location error classes from./location, and schema helpers from./schema.@codeworksh/schemais new on npm (0.0.0placeholder published and GitHub Actions trusted publisher configured forpublish.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/relayagainst real Postgres: 9 pass.extras/*pass. A release dry run orders aikit, schema, plugin, harness, cli.apps/webproduction build: verifiedHost.Apiand server error classes are excluded from the browser bundle.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 inprompt.changes.live.test.tsmade three requests where it expects two; the file passed when run again alone. Insea.test.ts, the offline plugin-sharing case (including@codeworksh/schema/{common,ids}with nonodeonPATH) and OpenAI (gpt-5.6-luna) live case pass; OpenRouter (meta/muse-spark-1.3-contributor) returned no tool calls.account, and Relay's row has the matchingaccount_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 inapp.db), and verified the sidebar, Threads, and Settings → Machines pages render with zero console errors.apps/server, on four machines:sync(12/12),recovery,usage(6/6) andmetrics.simulationpass, 31 cases (withusageandsyncre-run after review fixes). The foursync.machinesartifacts that lost theirorganization_idlines pass unchanged.synccases and onemetricscase failed oncanarytoo: replacing a machine's store also dropped itsmachine.json, so the app refused the machine's new key and never synced it again. The fixtures keepdevices.jsonandmachine.jsonnow.canarytoo: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 asserver.connected, and the artifact from before expects only the latter. Left as it is: whether the replay is intended is a separate decision.test:sandbox:packagein 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-botwith what you need.