Skip to content

prototype(sdk): patchy init --tier 1, dev over PGlite, publish with manifest - #187

Closed
allisonmahmood wants to merge 2 commits into
mainfrom
prototype/init-tier1
Closed

allisonmahmood wants to merge 2 commits into
mainfrom
prototype/init-tier1

Conversation

@allisonmahmood

Copy link
Copy Markdown
Owner

What changed

Prototype, not for merge. It is up so the team can check it out and try the agent's first ten minutes with a patch repo: patchy init --tier 1, patchy dev over PGlite, patchy publish with a manifest. The question it answers, and everything learned, is on the ticket: Prototype: patchy init --tier 1, code-first config, first table and file over PGlite, first publish.

Today a patch is one HTML file with no repo. The SDK map decided a patch is a file tree with a code-first patchy.config.ts, tables and file stores provisioned for it on publish, and a local dev loop on the real capability code. Nothing existed to feel whether that shape is right for an agent. This branch builds the smallest version of all three legs on real code:

  • @patchy/sdk: defineConfig / table / files / t.* and a dependency-free browser client typed by inference from the config.
  • @patchy/primitives: the Tables and Files capability services (additive provisioning from a manifest, bounded reads and writes) and the /_patchy/* routes, composed by the server over Postgres and by patchy dev over PGlite.
  • POST /api/publish on the wire, versions carrying tier and manifest, tier 1 bundles served under a sandbox CSP.
  • CLI: init, dev, publish, refresh.

Part of #176 (left open for the verdict; this PR closes nothing).

Try it

pnpm install && pnpm dev                      # this worktree's instance, seeded Dev Machine key
mkdir -p /tmp/try && cd /tmp/try
set -a; . <worktree>/.local/dev/env; set +a  # PATCHY_API_URL and PATCHY_API_TOKEN
alias patchy='node --import <worktree>/node_modules/tsx/dist/loader.mjs --conditions=development <worktree>/packages/cli/src/index.ts'
patchy init --tier 1 notes && cd notes        # read AGENTS.md and the skill it points at
patchy dev                                    # one URL; add a note in the browser
patchy publish --share public                 # open the URL; check p_<id>.notes in Postgres

Then change patchy.config.ts: add a column and a table (publish again, see them provisioned), rename a column (refused), set tier: 0 (refused).

How it was verified

  • pnpm test, pnpm typecheck pass. pnpm lint does not: the CLI's flat-directory import rule and template escapes in the laid-down tree strings, left as-is on a throwaway branch.
  • Ran end to end against this worktree's dev instance on 2026-09-06, then handed the laid-down tree to a fresh agent session (astra through omp) with only the tree and patchy on PATH; it added a table and an image upload and published. Its findings and astra's second-model review are on the ticket.
  • Added or updated tests covering this change — deliberately none; prototype.

Release impact

  • Breaking
  • Not breaking — never merges; nothing running Patchy Cloud sees it.

Built by Claude Fable 5.1 in Claude Code, working the SDK map.

allisonmahmood and others added 2 commits September 6, 2026 18:56
…anifest (#176)

Throwaway prototype for the SDK map's init ticket. Adds @patchy/sdk (code-first
config and browser client), @patchy/primitives (Tables and Files services plus
the /_patchy routes), a publish route that provisions additively before
recording the version, and the init/dev/publish/refresh CLI commands.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@github-actions github-actions Bot added area:server Touches the server area area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:docs Touches the docs area size:l 501-1,000 changed lines labels Sep 6, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

DO NOT MERGE!!

@vsrikar08

vsrikar08 commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator

Good prototype for 187. Again, remember what i said about building the sdk gradually even for tier 1.

@vsrikar08

vsrikar08 commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator

Make sure that when the SDK calls patchy, the production mounts those routes first.

@vsrikar08

vsrikar08 commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator

I see a bit of an issue with the way we store things. Like Heres the thing. Will we be saving drafts if they aren't published? If so, that can cause database issues. writing into other patches, corrupting data, etc. We have to find a way for that not to happen. Maybe only one draft at a time per page? Maybe have a saved section and have one default autosaved page at a time.

@vsrikar08

vsrikar08 commented Sep 8, 2026 •

Copy link
Copy Markdown
Collaborator

Make sure when you delete a patch page, we delete everything with it. Tables, schemas, stored files, etc

@vsrikar08

vsrikar08 commented Sep 8, 2026 •

Copy link
Copy Markdown
Collaborator

We should also have a policy on how the sdk and patches interact with users. IE if we share a patch, can the other person edit it (Now this would be a sick feature ngl) . Ie how that would work.

@vsrikar08

Copy link
Copy Markdown
Collaborator

I think something that will help us debug the sdk when building it is by having very specific error handling. WIll make our work a lot easier instead of beating the bush for 3 hours.

@vsrikar08

Copy link
Copy Markdown
Collaborator

Browser app calls patchy -> SDK sends an HTTP request->Vite forwards it to the local Patchy runtime-> Runtime checks the declared table and row fields -> Tables service writes to local PGlite database-> Saved row returns through the same path.
This is basically the flow. I think our two biggest issues are gonna be database corruption and local to production (basically publishing). Especially now we have to deal with the whole asych vs synch (https). Both are vital for tier 1 patches.

@vsrikar08

Copy link
Copy Markdown
Collaborator

We also need something like the patchy gates to say, hey we cannot do this. But where that line is something we struggled with in the patchy crm. We cannot afford to make the mistake here. How can we not overdo it is gonna be a big question.I think for now drawing strict boundaries between the tiers will do. aka no cron, etc. shit for now. but we dont want that going into the future.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Closing as not for merge; the prototype answered its question. Findings and the resolution are on #176 (#176 (comment)). The branch stays until #179, #181, #182 and #183 have lifted what they need; delete it then.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Final prototype cleanup for #209: this not-for-merge PR remains closed. The local PGlite runtime was lifted by #207 (PR #223), and init, generation and project commands by #204 (PR #220). Deleting only the remote prototype/init-tier1 branch; local branches and worktrees are untouched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:docs Touches the docs area area:server Touches the server area size:l 501-1,000 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants