Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 110 additions & 25 deletions fork/manifest.json

Large diffs are not rendered by default.

255 changes: 255 additions & 0 deletions packages/core/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@
"name": "session_share",
"entityType": "tables"
},
{
"name": "claims",
"entityType": "tables"
},
{
"type": "text",
"notNull": false,
Expand Down Expand Up @@ -1480,6 +1484,186 @@
"entityType": "columns",
"table": "session_share"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "id",
"entityType": "columns",
"table": "claims"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "project_id",
"entityType": "columns",
"table": "claims"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "slug",
"entityType": "columns",
"table": "claims"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": "implement",
"generated": null,
"name": "kind",
"entityType": "columns",
"table": "claims"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "holder_session",
"entityType": "columns",
"table": "claims"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "holder_harness",
"entityType": "columns",
"table": "claims"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "holder_name",
"entityType": "columns",
"table": "claims"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "branch",
"entityType": "columns",
"table": "claims"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "worktree",
"entityType": "columns",
"table": "claims"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "provider_id",
"entityType": "columns",
"table": "claims"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "model_id",
"entityType": "columns",
"table": "claims"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "gate",
"entityType": "columns",
"table": "claims"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "since",
"entityType": "columns",
"table": "claims"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "heartbeat",
"entityType": "columns",
"table": "claims"
},
{
"type": "integer",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "released_at",
"entityType": "columns",
"table": "claims"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "release_reason",
"entityType": "columns",
"table": "claims"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "time_created",
"entityType": "columns",
"table": "claims"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "time_updated",
"entityType": "columns",
"table": "claims"
},
{
"columns": ["project_id"],
"tableTo": "project",
Expand Down Expand Up @@ -1623,6 +1807,17 @@
"entityType": "fks",
"table": "session_share"
},
{
"columns": ["project_id"],
"tableTo": "project",
"columnsTo": ["id"],
"onUpdate": "NO ACTION",
"onDelete": "CASCADE",
"nameExplicit": false,
"name": "fk_claims_project_id_project_id_fk",
"entityType": "fks",
"table": "claims"
},
{
"columns": ["email", "url"],
"nameExplicit": false,
Expand Down Expand Up @@ -2065,6 +2260,66 @@
"name": "todo_session_idx",
"entityType": "indexes",
"table": "todo"
},
{
"columns": [
{
"value": "project_id",
"isExpression": false
},
{
"value": "slug",
"isExpression": false
}
],
"isUnique": true,
"where": "released_at IS NULL",
"origin": "manual",
"name": "claims_project_slug_live_idx",
"entityType": "indexes",
"table": "claims"
},
{
"columns": [
{
"value": "holder_session",
"isExpression": false
}
],
"isUnique": false,
"where": null,
"origin": "manual",
"name": "claims_holder_idx",
"entityType": "indexes",
"table": "claims"
},
{
"columns": [
{
"value": "project_id",
"isExpression": false
}
],
"isUnique": false,
"where": null,
"origin": "manual",
"name": "claims_project_idx",
"entityType": "indexes",
"table": "claims"
},
{
"columns": [
{
"value": "slug",
"isExpression": false
}
],
"isUnique": false,
"where": null,
"origin": "manual",
"name": "claims_slug_idx",
"entityType": "indexes",
"table": "claims"
}
],
"renames": []
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/database/migration.gen.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions packages/core/src/database/migration/20260919055032_add_claims.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Effect } from "effect"
import type { DatabaseMigration } from "../migration"

export default {
id: "20260919055032_add_claims",
up(tx) {
return Effect.gen(function* () {
yield* tx.run(`
CREATE TABLE \`claims\` (
\`id\` text PRIMARY KEY,
\`project_id\` text NOT NULL,
\`slug\` text NOT NULL,
\`kind\` text DEFAULT 'implement' NOT NULL,
\`holder_session\` text,
\`holder_harness\` text,
\`holder_name\` text,
\`branch\` text,
\`worktree\` text,
\`provider_id\` text,
\`model_id\` text,
\`gate\` text,
\`since\` integer NOT NULL,
\`heartbeat\` integer NOT NULL,
\`released_at\` integer,
\`release_reason\` text,
\`time_created\` integer NOT NULL,
\`time_updated\` integer NOT NULL,
CONSTRAINT \`fk_claims_project_id_project_id_fk\` FOREIGN KEY (\`project_id\`) REFERENCES \`project\`(\`id\`) ON DELETE CASCADE
);
`)
yield* tx.run(`CREATE UNIQUE INDEX \`claims_project_slug_live_idx\` ON \`claims\` (\`project_id\`,\`slug\`) WHERE \`released_at\` IS NULL;`)
yield* tx.run(`CREATE INDEX \`claims_holder_idx\` ON \`claims\` (\`holder_session\`);`)
yield* tx.run(`CREATE INDEX \`claims_project_idx\` ON \`claims\` (\`project_id\`);`)
yield* tx.run(`CREATE INDEX \`claims_slug_idx\` ON \`claims\` (\`slug\`);`)
})
},
} satisfies DatabaseMigration.Migration
27 changes: 27 additions & 0 deletions packages/core/src/database/schema.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,33 @@ export default {
CONSTRAINT \`fk_session_share_session_id_session_id_fk\` FOREIGN KEY (\`session_id\`) REFERENCES \`session\`(\`id\`) ON DELETE CASCADE
);
`)
yield* tx.run(`
CREATE TABLE \`claims\` (
\`id\` text PRIMARY KEY,
\`project_id\` text NOT NULL,
\`slug\` text NOT NULL,
\`kind\` text DEFAULT 'implement' NOT NULL,
\`holder_session\` text,
\`holder_harness\` text,
\`holder_name\` text,
\`branch\` text,
\`worktree\` text,
\`provider_id\` text,
\`model_id\` text,
\`gate\` text,
\`since\` integer NOT NULL,
\`heartbeat\` integer NOT NULL,
\`released_at\` integer,
\`release_reason\` text,
\`time_created\` integer NOT NULL,
\`time_updated\` integer NOT NULL,
CONSTRAINT \`fk_claims_project_id_project_id_fk\` FOREIGN KEY (\`project_id\`) REFERENCES \`project\`(\`id\`) ON DELETE CASCADE
);
`)
yield* tx.run(`CREATE UNIQUE INDEX \`claims_project_slug_live_idx\` ON \`claims\` (\`project_id\`,\`slug\`) WHERE \`released_at\` IS NULL;`)
yield* tx.run(`CREATE INDEX \`claims_holder_idx\` ON \`claims\` (\`holder_session\`);`)
yield* tx.run(`CREATE INDEX \`claims_project_idx\` ON \`claims\` (\`project_id\`);`)
yield* tx.run(`CREATE INDEX \`claims_slug_idx\` ON \`claims\` (\`slug\`);`)
yield* tx.run(`CREATE UNIQUE INDEX \`event_aggregate_seq_idx\` ON \`event\` (\`aggregate_id\`,\`seq\`);`)
yield* tx.run(`CREATE INDEX \`event_aggregate_type_seq_idx\` ON \`event\` (\`aggregate_id\`,\`type\`,\`seq\`);`)
yield* tx.run(
Expand Down
33 changes: 33 additions & 0 deletions packages/core/src/loop/sql.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core"
import { Timestamps } from "../database/schema.sql"
import { ProjectTable } from "../project/sql"
import { AbsolutePath } from "../schema"

export const ClaimKind = ["implement", "review", "integrate", "triage", "decide"] as const
export type ClaimKind = (typeof ClaimKind)[number]

export const ReleaseReason = ["completed", "quarantined", "abandoned", "cancelled", "human"] as const
export type ReleaseReason = (typeof ReleaseReason)[number]

export const ClaimTable = sqliteTable("claims", {
id: text().primaryKey(),
project_id: text()
.$type<typeof ProjectTable.$inferSelect.id>()
.notNull()
.references(() => ProjectTable.id, { onDelete: "cascade" }),
slug: text().notNull(),
kind: text().$type<ClaimKind>().notNull().default("implement"),
holder_session: text(),
holder_harness: text(),
holder_name: text(),
branch: text(),
worktree: text().$type<AbsolutePath>(),
provider_id: text(),
model_id: text(),
gate: text(),
since: integer().notNull(),
heartbeat: integer().notNull(),
released_at: integer(),
release_reason: text().$type<ReleaseReason>(),
...Timestamps,
})
Loading
Loading