-
Notifications
You must be signed in to change notification settings - Fork 66
Add plain repos primitive with explicit package promotion #1198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # Plain repos | ||
|
|
||
| Plain repos are Kody's base Artifacts-backed storage primitive. Every plain repo | ||
| maps to a Cloudflare Artifacts git repository via `entity_sources` with | ||
| `entity_kind = 'repo'`. They are **live-at-HEAD**: pushes and session publishes | ||
| materialize directly on the default branch with no `published_commit` publish | ||
| step and no external-push reconcile lane. | ||
|
|
||
| Saved packages are an **explicit extension**: a package is a repo whose | ||
| `entity_sources` row has `entity_kind = 'package'` and a matching | ||
| `saved_packages` projection. Activation is never inferred from contents—a root | ||
| `package.json` alone does not make a package. Use `repo_promote_to_package` when | ||
| you want runtime surfaces (exports, apps, services, jobs, webhooks). | ||
|
|
||
| ## Capabilities | ||
|
|
||
| | Capability | Purpose | | ||
| | ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | `repo_create` | Create a `user_repos` row and backing Artifacts repo (enforces `repos` entitlement). | | ||
| | `repo_list` | List plain repos from D1 (`user_repos`); no live Artifacts reads. | | ||
| | `repo_get` | One repo by id or name, live default-branch HEAD, `package_shaped` hint. | | ||
| | `repo_delete` | Delete `user_repos`, `entity_sources`, and Artifacts repo (best-effort). | | ||
| | `repo_get_git_remote` | Short-lived git remote; write pushes are live at HEAD (no publish reconcile). | | ||
| | `repo_promote_to_package` | Full publish checks + saved-package projection when root `package.json` exists at HEAD. | | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| | `repo_open_session` + session lane | File-level editing (`repo_edit_files`, `repo_apply_patch`, `repo_commit`, `repo_status`, `repo_diff`, `repo_log`, `repo_restore`, `repo_run_checks`, `repo_publish_session`, …) with `target: { kind: "repo", name }`. | | ||
|
|
||
| Vectorize/search integration for plain repos is not in v1—use `repo_list` for | ||
| discovery. | ||
|
|
||
| ## Git lane | ||
|
|
||
| `repo_get_git_remote` mints a short-lived Artifacts remote (read or write). | ||
| Kody's **10 MiB** per-file gate (10,485,760 stored bytes) binds on session and | ||
| file-level writes and again at `repo_promote_to_package`; a direct `git push` to | ||
| the minted remote has no Kody gate, so the only ceiling on that lane is | ||
| Artifacts itself, which rejects pushes above ~32 MiB of decompressed pack | ||
| content with a raw HTTP 413. Plain repos do not run the package publish | ||
| reconcile cron after push—HEAD is live. | ||
|
|
||
| ## Sessions | ||
|
|
||
| Open with `repo_open_session` using `target: { kind: "repo", name: "<name>" }` | ||
| or `source_id`. Session base is the current default-branch HEAD (not a publish | ||
| pointer). `repo_publish_session` on a plain repo runs only the source size walk | ||
| (manifest, bundle, typecheck, and lint checks are skipped). When the published | ||
| tree contains root `package.json`, the result includes `package_shaped: true` | ||
| and a promote notice. | ||
|
|
||
| ## Promote flow | ||
|
|
||
| When a plain repo has `package.json` at HEAD, `repo_get` and publish surfaces | ||
| surface progressive disclosure (`package_shaped`, `activated: false`, promote | ||
| notice). `repo_promote_to_package` enforces the `saved_packages` entitlement, | ||
| runs full publish checks, creates the `saved_packages` row, flips | ||
| `entity_sources` to `package`, and deletes the `user_repos` row. | ||
|
Comment on lines
+51
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift Make promotion failure-atomic. The promotion handler inserts the 🤖 Prompt for AI Agents |
||
|
|
||
| ## Mental model | ||
|
|
||
| Repos are the durable home for versioned source; packages add runtime surfaces | ||
| on top of an explicitly activated extension. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| CREATE TABLE user_repos ( | ||
| id TEXT PRIMARY KEY NOT NULL, | ||
| user_id TEXT NOT NULL, | ||
| name TEXT NOT NULL, | ||
| description TEXT NULL, | ||
| created_at TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP), | ||
| updated_at TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP) | ||
| ); | ||
|
|
||
| CREATE UNIQUE INDEX idx_user_repos_user_name ON user_repos(user_id, name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Propagate the plain-repo model through the architecture index.
The new entries establish repos as a first-class source, but related architecture sections still describe only package/job sources. Align the contracts before merge.
docs/contributing/architecture/data-storage.md#L329-L334: Update the laterentity_sourcescontract to includerepo, and distinguish package/job published commits from live-at-HEAD plain repos.docs/contributing/architecture/data-storage.md#L917-L924: Add plain-repo identity, live-at-HEAD behavior, and session/Git storage to the state mapping, or scope the heading to packages.docs/contributing/architecture/primitives.yaml#L176-L191: Update theartifacts-reposprimitive summary to include plain repos as a shared backing store.📍 Affects 2 files
docs/contributing/architecture/data-storage.md#L329-L334(this comment)docs/contributing/architecture/data-storage.md#L917-L924docs/contributing/architecture/primitives.yaml#L176-L191🤖 Prompt for AI Agents