Skip to content

patches: a Patchy source store so a lost repo can be pulled back #229

Closed

Description

@allisonmahmood

Problem

Publish stores only the built HTML bundle and the manifest per version. No source tree lives in the cloud. A person whose machine is gone has a running tool nobody can change again, and an agent cannot pull a colleague's patch to work on it.

Idea

Patchy runs its own source management: a git-backed store the CLI pushes to on publish (or explicitly), and patchy pull <patch> restores a working repo for the owner. No cloud working copy, branches, merges or collaborative editing; version-bound snapshots that recover a repo where patchy dev runs.

Decisions this needs before it is built:

  • what "pull" guarantees: editable source, or a repo where patchy dev runs (package pin, generated files, fixtures, release compatibility)
  • the archive boundary: project skills and config live in dotfiles, so "no dotfiles" breaks it; tracked files can hold secrets, so an inspectable upload inventory rather than promised secret detection
  • authority: public HTML never means public source; whether an admin or a reassigned owner may pull
  • publish coupling: whether a failed source push fails the publish
  • historical gaps: existing versions and file-born patches have no source
  • retention: snapshots take part in retire, restore and permanent delete

Why not now

Ruled out of the portal map (deployed-stage spec, 2026-09-12) so that map stays on finding and managing patches. The SDK map had already ruled out Patchy as a source-control tool; this issue narrows that to recovery.

Activity

  1. added
    enhancement
    on Sep 12, 2026
  2. vsrikar08 commented on Sep 14, 2026

    @vsrikar08
    Collaborator

    To simplify it (just for commenting. SOmething around the lines of save button, input gets saved (enough of it to remake it anywhere else easily), user can access download and hook it up to cli

  3. vsrikar08 commented on Sep 14, 2026

    @vsrikar08
    Collaborator

    See, the inherent problem is you can't just save the prompt (aka the input). Because then the recreated "saved progress" dashboard will probably not look like the original. ON the other hand, we can't save everything otherwise our database is gonna be overcrowded with useless junk.

  4. vsrikar08 commented on Sep 14, 2026

    @vsrikar08
    Collaborator

    What matters at the end of the day:
    say we talk to it similar to grill me, what matters the most will be the decisions we make at the end of the day. When we make say a dashboard and we choose what goes in it and what doesn't etc.
    We need to know the libraries it used, configurations, integrations, etc
    This is what we need to recreate it on another computer. The original prompt would not be enough and the full agent convo might be a lot of overhead. At the end of the day the main issue is that we need to preserve enough to keep building it.**

  5. vsrikar08 commented on Sep 14, 2026

    @vsrikar08
    Collaborator

    From my understanding, the final out put is basically a folder with a lot of files (i know ) and 1 or 2 of those files are the things we need to run the patch inside and actually upload.
    Basically, we have a local folder with source code, configuration, agent instructions, and supporting files.
    We then edit that project
    Then we run "Patchy publish", which builds it into **one self-contained HTML file, then uploads that and a manifest describing the patch. And we retain a copy of it on our laptop
    Alternatively, we can also publish the HTML file directly, without creating a project folder.

  6. vsrikar08 commented on Sep 14, 2026

    @vsrikar08
    Collaborator

    A markdown file with all the useful shit would make sense but it still might rebuild the thing differently, so thats an issue, so we need the files there as well. Tradeoffs

  7. vsrikar08 commented on Sep 14, 2026

    @vsrikar08
    Collaborator

    what we want at the end of the day is for the user say to go on a different computer and resume their progress or if they quit a patch for whatever reason (on their own laptop) and go to a different patch and start working on that and decide they want to go back to the patch they quit for whatever reason and they lost the downloaded copy. Those are the usecases i can think on top of my head.

  8. vsrikar08 commented on Sep 14, 2026

    @vsrikar08
    Collaborator

    Couple solutions: The idea of a git type thing where a user can "pull" from if shit goes wrong is not bad because at the end of the day we need the project files if we don't wanna rebuild every fucking time.
    The alternative in this case would be letting the user rebuild every time with a markdown file but then it probably won't be exact to the original build. While a markdown would have important context, it will not be exact, which is a requirement in this case
    The biggest issue I can see with the git thing is that we have to be very active in deleting old content. Perhaps a timer where we delete after 30 days?
    Another solution is an external git repo connected to our database thats going to be really tacky when you consider cloud accounts and stuff. Not really necessary to be this complex right now, but something to keep in mind in the future.

    I think the best compromise here is something around the lines of “recover my project and keep editing,” in that sense, straightforward storage. So what would happen is that the cli packages source code, assets, configuration, dependency versions, agent md file, etc and stores it. This is what we would pull.

    Because if the project is already compiled (aka they have a draft and still editing it) and the user wants to keep editing it, we have to keep that exact version and a snapshot for reference.

    We can't just have a Markdown file and have the agent replicate it because it wouldn't be the same thing, even with a snapshot alongside it. So maybe a zip file to preserve the patch's contents and folder structure, similar to a git snapshot.

  9. vsrikar08 commented on Sep 14, 2026

    @vsrikar08
    Collaborator

    For the database:
    Now I am thinking of deleting removed patches permanently after 30 days as to control overhead., keep the latest source snapshot/files, remove everything linked to the patch if its deleted (not archived) (we should have a trash button where we can restore deleted patches but that can come later) .
    Alternatively, since the user might want to go back to a previous version, we could keep the latest snapshot while the patch exists; keep the older snapshots for 30 days (previous versions) and then delete them.

  10. vsrikar08 commented on Sep 14, 2026

    @vsrikar08
    Collaborator

    to summarize

    1. upload the finished HTML, manifest, and a source snapshot stored as an archive or through Git.

    2. store code, configuration, dependency versions, assets, and agent instructions, including useful Markdown context.

    3. the user runs patchy pull on another computer. It restores the project and sets it up for patchy dev, still targeting the same patch and its existing cloud resources.

    4. edit and publish the next version.

    The database and zip file are seperate. What this means is we have a seperate database and a different storage for the zip file. The database just tracks its location and metadata.

  11. vsrikar08 commented on Sep 14, 2026

    @vsrikar08
    Collaborator

    How I would build it.
    It's more as lets go along and build it along the way.
    But the way I would go about building it is
    CLI: build HTML and archive source -> Authenticated publish API -> Content storage: HTML and ZIP -> Postgres: version and snapshot metadata (what I mean by seperate database and storage- > api pull request- > cli restores project
    Basically we have two artifacts in this case when we publish: carry the source archive alongside the HTML and manifest and the postgres layer would hold a small record of stuff like patch_id, created, etc and this would point to the zip in the existing content storage area. Obviously lot of smaller decisions but this is how I would go about it on a top level.

  12. vsrikar08 commented on Sep 14, 2026

    @vsrikar08
    Collaborator

    Specifically and technically speaking (before you get mad at me)
    I have theories on how I would go about the CLI packaging and publish contract and how I would include all the necessary files and how I would expand the already to wire the database to access the previously written versions and objects
    Also how I would do source retrieval (this should be simple, just adding an authentication route would do in theory). Basically, the server resolves authorization through the current patch owner, checks patch availability, and returns:content type and zip file.
    And how I would go about retention and deletion. However these are things I should probably test and try out firsthand as these are much smaller decisions. . Aka I should go about this one at a time and test shit out starting with the zip storage and CLI packaging.

  13. allisonmahmood commented on Oct 28, 2026

    @allisonmahmood
    OwnerAuthor

    Plan: every version keeps its repo, and patchy pull gets it back

    Decided with Allison on 2026-10-29, then reviewed by GPT 6.1 Sol. This is #546's step 1 ("every version carries its source") on the content store, without waiting for Versie. Versie can later import these snapshots as its first checkpoints.

    Decisions

    • One request. A publish from a repo carries the repo's files inside the same request as the bundle, so the publish key and payload digest cover them, and no version the CLI publishes exists without them.
    • Who can pull: anyone the patch is openable for, which today is every member of its company. Publish stays owner-only. Public sharing never exposes the repo: pull is a machine-token API read, like every other one, and guest openability must never widen it.
    • What goes in: everything except .gitignored paths (nested .gitignores honoured), .git/, any node_modules/, .patchy/, patchy/_generated/, .agents/skills/patchy-*/, .env, .env.* and .DS_Store.
      • The caps are 10 MiB of file bytes and 2,000 files. Over either, publish refuses and names the five largest top-level entries, so the agent adds them to .gitignore.
      • Symlinks are skipped with a warning naming them. Publish refuses when a file the CLI needs (package.json, patchy.config.ts, patchy.json, index.html, vite.config.ts) is ignored.
    • patchy pull <patch> [dir] gets the served version, and --version N gets another.
      • It writes the files and stamps patchy.json: this instance, the patch id, the version and the cloud description.
      • It then runs refresh's own sequence: managed pin, install, generation, workerd pin and second install, toolchain check, fixture-preserving activation. patchy dev works on today's release straight away.
      • For a patch that isn't live, or when setup fails (for example a connection that was removed), it keeps the files and names the reason and the next step.
      • A file-born tier 0 page pulls as its one HTML file, under a sanitized name.
    • Stale copies. patchy.json records the version a copy was published as or pulled from. Publishing from a copy older than the patch's newest version refuses with behind, naming that version and who published it.
      • The check runs before upload and again under the patch row lock.
      • patchy publish --allow-behind publishes anyway. It is separate from --force, which also overrides the protection for dependants.
    • CLI and API only in v1. A portal line comes later, with mocks first.

    Term

    Repo snapshot: the files of the patch repo one version was published from, minus managed files and what .gitignore excludes. Columns and objects are repo_*. Avoid calling it "source", which already names shared-resource sources, connected sources and source_ip.

    Wire

    • PublishRequest.repo?: { path, contents (base64) }[]. Paths are relative POSIX, have no ./../empty segments and no control characters, and are at most 1,024 bytes. The server refuses:
      • duplicates under NFC and case folding
      • a path that is both a file and a directory
      • more than the limits publish.repo.files and publish.repo.bytes (413)
    • PublishRequest.baseVersion?: int. The --allow-behind override sends no new field: it omits baseVersion.
    • The publish response gains artifacts.repo: { files, bytes }, with bytes counting the decoded file bytes.
    • GET /api/patches/:patchRef/repo?version=N&state=… (pull) uses detail's resolution, openability and state filter. It returns the version, owner, description, kind: repo | file and the files.
      • A version with no snapshot answers 404 no_repo, naming the owner.
    • PatchDetail.repo describes the served version's snapshot, or null.

    Server

    • Migration 0029: repo_object_key, repo_content_hash, repo_file_size and repo_file_count on patch_versions, all or none, with a unique index.
    • The snapshot is stored as canonical JSON at patches/<id>/versions/<ver>.repo.json through the existing pending-object intent path. It is part of intent consumption at commit, of the expired-intent claim and of the purge queue.

    Delivery

    Three stacked PRs:

    1. Server: versions keep a repo snapshot, and members can read it. Nothing sends one yet, so it ships alone.
      • It is labelled one-way: once a later release stores snapshots, rolling back past it would let the old purge drop version rows without queueing their repo objects. That leaves company code in the object store after its deletion.
      • So it deploys in its own release before PR 2 ships.
    2. CLI: publish sends the repo, patchy pull restores it, and patchy list says whether it can. It also writes the version into patchy.json passively.
    3. Publish refuses a copy behind the newest version.

    Each PR updates the docs and skills it touches (API and limits docs, README, ADR-0004, global and project skills, the AGENTS.md template, both glossaries, docs/product.md).

    Not in v1

    • Portal surfaces.
    • Per-file dedup.
    • Drafts or saves outside publish.
    • Rebuilding repos for versions published before this ships.
    • Pulling into an existing folder.
    • A git export.
    • Secret scanning beyond the fixed exclusions.

    Filed by Claude Opus 5.5 via Claude Code for Allison.

  14. allisonmahmood commented on Oct 31, 2026

    @allisonmahmood
    OwnerAuthor

    Shipped in production as two releases:

    A patch built in a repo before release 29 has no snapshot until its owner publishes it once with patchy 0.29.0. Pages published from one HTML file pull back as that file already. The plan's "Not in v1" list above is still unbuilt, starting with a portal line.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions