Make skills spec-compliant#39
Conversation
Greptile SummaryThis PR replaces the agentskills.io-spec skill model with an OpenAI-compatible, immutable versioned design: a
Confidence Score: 4/5The versioning logic and security controls are solid, but the in-place migration mutation will break sqlx migrate run on any database that already applied the old schema. The core redesign is well-engineered with FOR UPDATE/BEGIN IMMEDIATE guards, zip-bomb protection, and correct org-scoping. The one deployment concern is the modified initial migration — sqlx checksums applied migrations, so existing databases will hit a hard failure. Both migrations_sqlx/postgres/20250101000000_initial.sql and migrations_sqlx/sqlite/20250101000000_initial.sql need attention — a new additive migration file is the safe path for existing databases. Important Files Changed
Entity Relationship Diagram%%{init: {'theme': 'neutral'}}%%
erDiagram
skills {
UUID id PK
skill_owner_type owner_type
UUID owner_id
VARCHAR name
BIGINT default_version_seq
BIGINT latest_version_seq
BIGINT next_version_seq
}
skill_versions {
UUID id PK
UUID skill_id FK
BIGINT version_seq
VARCHAR name
VARCHAR description
BIGINT total_bytes
}
skill_version_files {
UUID skill_version_id FK
VARCHAR path
TEXT content
BIGINT byte_size
}
skills ||--o{ skill_versions : "has versions"
skill_versions ||--o{ skill_version_files : "contains files"
skills }o--|| skill_versions : "default_version_seq"
skills }o--|| skill_versions : "latest_version_seq"
Prompt To Fix All With AIFix the following 3 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 3
migrations_sqlx/postgres/20250101000000_initial.sql:1202
**In-place mutation of an already-applied migration breaks existing databases**
`sqlx` records the SHA256 checksum of every applied migration in `_sqlx_migrations`. Because `20250101000000_initial.sql` has been modified rather than a new migration added, any database that already ran the old version will fail with `"migration was previously applied but its source has changed"` on the next `sqlx migrate run`. This affects every developer's local database, staging, and any CI pipeline that doesn't start from a clean schema. A new migration file (e.g. `20250530000000_skills_versioned.sql`) with `ALTER TABLE`, `CREATE TABLE`, and a data backfill is needed for existing deployments. The same applies to `migrations_sqlx/sqlite/20250101000000_initial.sql`.
### Issue 2 of 3
ui/src/pages/chat/useChat.ts:2360-2372
**Skill seed silently dropped on fetch failure**
`clearPendingSkill()` is called before `loadSkillSeed`, so if the fetch fails (network error, 404, or a cached skill missing its `files` array) and `seed` is `null`, the message is sent without the skill's `SKILL.md` injected and without any user-visible feedback. From the user's perspective they invoked a skill but the model responds as if it wasn't there. Consider toasting an error or, at minimum, restoring `pendingSkillId` on failure so the user can retry.
### Issue 3 of 3
src/routes/api/skills.rs:1324-1342
**Non-atomic version-count enforcement allows limit overshoot under concurrency**
`count_versions` and `create_version` are two separate DB round-trips with no transaction or lock between them. Two concurrent `POST /v1/skills/{id}/versions` requests can both observe `count < max` and both proceed to insert, leaving the skill one or more versions over `max_skill_versions_per_skill`. Since the default limit is 0 (unlimited), this only matters when an operator explicitly configures the cap — but once they do, the limit is not reliably enforced. Enforcing the cap inside the `create_version` DB transaction (e.g. a `SELECT COUNT … FOR UPDATE` before the insert) would close the gap.
Reviews (5): Last reviewed commit: "Seed slash-invoked skills directly into ..." | Re-trigger Greptile |
| @@ -1198,26 +1202,20 @@ CREATE TABLE IF NOT EXISTS skills ( | |||
| id UUID PRIMARY KEY NOT NULL, | |||
There was a problem hiding this comment.
In-place mutation of an already-applied migration breaks existing databases
sqlx records the SHA256 checksum of every applied migration in _sqlx_migrations. Because 20250101000000_initial.sql has been modified rather than a new migration added, any database that already ran the old version will fail with "migration was previously applied but its source has changed" on the next sqlx migrate run. This affects every developer's local database, staging, and any CI pipeline that doesn't start from a clean schema. A new migration file (e.g. 20250530000000_skills_versioned.sql) with ALTER TABLE, CREATE TABLE, and a data backfill is needed for existing deployments. The same applies to migrations_sqlx/sqlite/20250101000000_initial.sql.
Prompt To Fix With AI
This is a comment left during a code review.
Path: migrations_sqlx/postgres/20250101000000_initial.sql
Line: 1202
Comment:
**In-place mutation of an already-applied migration breaks existing databases**
`sqlx` records the SHA256 checksum of every applied migration in `_sqlx_migrations`. Because `20250101000000_initial.sql` has been modified rather than a new migration added, any database that already ran the old version will fail with `"migration was previously applied but its source has changed"` on the next `sqlx migrate run`. This affects every developer's local database, staging, and any CI pipeline that doesn't start from a clean schema. A new migration file (e.g. `20250530000000_skills_versioned.sql`) with `ALTER TABLE`, `CREATE TABLE`, and a data backfill is needed for existing deployments. The same applies to `migrations_sqlx/sqlite/20250101000000_initial.sql`.
How can I resolve this? If you propose a fix, please make it concise.
No description provided.