Rebuild: schema for groups, rule sets, ranges, release catalog, chunk store, fragments, probe queue, rule bookkeeping and nodes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Daan MeijerandClaude Opus 5.5 committed 2026-10-09 00:19:00 +02:00
1 parent a18ead666b
commit 2209921846
11 files changed
+1228

No files matched your search

@@ -0,0 +1,38 @@
import { BaseSchema } from '@adonisjs/lucid/schema'
/**
* A group's history in leasable pieces (REBUILD.md, coordinator):
* planned → (spooled by the prefetcher) → leased → done. `next_id` is the
* resume point: everything before it has been stored.
*/
export default class extends BaseSchema {
async up() {
this.schema.createTable('ranges', (table) => {
table.bigIncrements('id')
table.integer('group_id').notNullable().references('id').inTable('groups').onDelete('CASCADE')
table.bigInteger('start_id').notNullable()
table.bigInteger('end_id').notNullable()
table.bigInteger('next_id').notNullable()
table.string('status', 8).notNullable().defaultTo('planned')
// Lower first; the coordinator plans the oldest era first.
table.integer('priority').notNullable().defaultTo(0)
table.integer('rule_version').nullable()
table.integer('node_id').nullable()
table.integer('attempts').notNullable().defaultTo(0)
// Chunks of this range in the spool (prefetch); all of them when spooled_at is set.
table.integer('spooled_chunks').notNullable().defaultTo(0)
table.timestamp('spooled_at', { useTz: true }).nullable()
table.timestamp('leased_at', { useTz: true }).nullable()
table.timestamp('heartbeat_at', { useTz: true }).nullable()
table.timestamp('done_at', { useTz: true }).nullable()
table.bigInteger('headers').notNullable().defaultTo(0)
table.text('error').nullable()
table.unique(['group_id', 'start_id'])
})
this.schema.raw(`CREATE INDEX ranges_todo_idx ON ranges (priority, id) WHERE status IN ('planned', 'leased')`)
}
async down() {
this.schema.dropTable('ranges')
}
}