Skip to content

fix: bootstrap sqlite task runtime schema - #26

Merged
zccz14 merged 5 commits into
mainfrom
spec/sqlite-auto-init
Apr 18, 2026
Merged

zccz14 merged 5 commits into
mainfrom
spec/sqlite-auto-init

Conversation

@zccz14

@zccz14 zccz14 commented Apr 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • clarify the sqlite task runtime spec and implementation plan around bootstrap-owned schema setup
  • make the sqlite runtime initialize and repair the task_runs schema before inserts and reads
  • add repo coverage for automatic table creation and done-column repair behavior

Verification

  • pnpm run test:repo

Copilot AI review requested due to automatic review settings April 18, 2026 16:39
@vercel

vercel Bot commented Apr 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cz-stack-web Ready Ready Preview, Comment Apr 18, 2026 4:39pm

@zccz14
zccz14 enabled auto-merge (squash) April 18, 2026 16:39
@zccz14
zccz14 merged commit 221b373 into main Apr 18, 2026
6 checks passed
@zccz14
zccz14 deleted the spec/sqlite-auto-init branch April 18, 2026 16:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR clarifies and enforces “bootstrap-owned” SQLite initialization for the task runtime by having the runtime create/validate the tasks table on open, with accompanying repo-level tests and updated design/plan docs.

Changes:

  • Add runtime-side bootstrap + schema compatibility checks when opening <project_dir>/aim.sqlite.
  • Update repo tests to cover empty-project bootstrapping and incompatible schema failure, plus plugin entrypoints on an empty project.
  • Update the spec and implementation plan to explicitly scope bootstrap behavior (create DB file + tasks table only; fail fast otherwise).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
test/repo/sqlite-task-runtime-plugin.test.ts Removes manual table creation in helpers and adds coverage for empty-project bootstrap and incompatible schema behavior.
docs/superpowers/specs/2026-04-18-sqlite-task-runtime-design.md Clarifies bootstrap responsibilities and the “fail fast on incompatible schema” boundary.
docs/superpowers/plans/2026-04-18-sqlite-task-runtime.md Updates the plan/constraints to include bootstrap and explicitly exclude migrations/repairs.
.opencode/plugins/task-runtime-sqlite/database.ts Implements tasks table bootstrap/validation during openTaskRuntimeDatabase.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +25 to +36
const createTasksTable = (database: DatabaseSync) => {
database.exec(`
CREATE TABLE tasks (
task_id TEXT NOT NULL,
task_spec TEXT NOT NULL,
session_id TEXT,
worktree_path TEXT,
pull_request_url TEXT,
status TEXT,
done INTEGER NOT NULL DEFAULT 0,
updated_at TEXT
)

Copilot AI Apr 18, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createTasksTable uses plain CREATE TABLE tasks (...) without IF NOT EXISTS. Since openTaskRuntimeDatabase can be called concurrently (e.g. multiple tool executions hitting an empty project), this can race and throw table tasks already exists. Consider making the DDL idempotent (CREATE TABLE IF NOT EXISTS) and/or wrapping the bootstrap in a transaction so concurrent callers don’t fail spuriously.

Copilot uses AI. Check for mistakes.
Comment on lines +34 to +40
- 运行时只自动创建 `<project_dir>/aim.sqlite` 与缺失的 `tasks` 表;不新增 schema migration、自动修表或兼容性回填逻辑。
- 插件对外只暴露题述 6 个 tools,不新增调试、迁移、schema 管理或手工 `task_id` 操作工具。
- 所有 task-bound tools 都只能从当前 tool context 的 `sessionID` 反查绑定 Task;若不存在唯一绑定,必须显式失败。
- `mark-task-status` 只允许一个 `status` 参数,并由插件统一维护 `updated_at` 与 `done` 派生关系。
- `dispatch-tasks` 必须覆盖 5 条分支:扫描 `done = false`、恢复已有 session、busy session 跳过、失效 session 重认领、未绑定 task 创建并绑定新 session 后发送首条 prompt。
- prompt 只能暴露 Task 快照,不得出现 `aim.sqlite`、`dbPath`、`SELECT`、`UPDATE`、表名或 SQL 规则。
- 若数据库可打开但现有 `tasks` schema 与运行时要求不兼容,相关入口必须显式失败,不尝试迁移。

Copilot AI Apr 18, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description mentions “initialize and repair the … schema” and “done-column repair behavior”, but this plan/spec explicitly says the runtime must not do schema migration/repair and should fail fast on incompatible tasks tables. Please align the PR description (or the plan) so reviewers/users aren’t misled about whether schema repair is expected.

Copilot uses AI. Check for mistakes.

This branch was successfully deployed

1 active deployment
Preview — 067489f5 Deployed Apr 18, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants