You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The seed tables' unique index is never created: both owners list two migrations at version 1 #1367
The unique index that allows one ready seed per kind is never created, on either platform.
iosSourceDataOwner and androidSourceDataOwner each declare version: 1 with two entries in migrations: the CREATE TABLE, then the CREATE UNIQUE INDEX … WHERE kind = 'seed' AND state = 'ready'. openStateDatabase runs one entry per version step (src/state/open.ts, database.exec(owner.migrations[from]) for from < owner.version), so only the first runs.
Seen at e3a497278: a state.db opened with both owners holds the two tables and no index.
owners: ios-source-data version 1, 2 migrations; android-source-data version 1, 2 migrations
objects: table android_source_data, table ios_source_data, table schema_versions
Found on the slow lane: two ready iOS seed rows with one spec_key sat in one state.db (a row a test helper inserted with a damaged key, and the driver's own). The drivers' per-kind lock is what keeps one seed per kind today; the index would have refused the second row.
A fix has to reach databases already at version 1, so it is a version 2 step, not a change to step 1.
src/drivers/ios/source-data.ts:3-27 and src/drivers/android/source-data.ts:3-27: version: 1 with two entries in migrations (table, then the *_ready_seed partial unique index).
src/state/open.ts:159-161: migrateOwner runs migrations[from] for from in stored..version-1, so step 0 runs and step 1 never does. It is a defect, not a gap.
No test names ios_source_data_ready_seed or android_source_data_ready_seed, so nothing catches it today.
Bump both owners to version: 2, with the index as step 2 (index [1]), as the issue says. Step 1 stays the same so databases already at version 1 pick it up.
A database that already holds two ready seed rows for one spec_key (as on the slow lane) makes CREATE UNIQUE INDEX fail. Then migrateOwner refuses the start with "could not move from version 1 to 2". The fix should decide whether step 2 first deletes or marks the extra rows, or whether that refusal is fine.
A guard worth having: openStateDatabase, or a test, checks migrations.length === version for each owner, so the next owner can't make this mistake.
Labels: added platform:ios and platform:android. Kept bug:new. The full rule 8 report (failing test, fast-track lines) and bug:ready are left to the triage-bug run or the maintainer.
Confirmed: both seed tables lack the index, on a new state.db and on one at version 1. Branch bug/1367-repro, src/daemon/state-owners.test.ts, "the seed tables' one-ready-seed-per-kind index (#1367)": five cases (two per platform, plus one over every owner). All five fail on main.
pnpm exec vitest run --project unit src/daemon/state-owners.test.ts
✗ ios_source_data / android_source_data: a new state.db refuses a second ready seed of one kind, ...
AssertionError: expected [Function] to throw an error
✗ ios_source_data / android_source_data: a state.db at version 1 moves to version 2 at open, keeping the newest ready seed of each kind (a tie kept by the larger source id), demoting the others to making, ...
AssertionError: expected { version: 1 } to deeply equal { version: 2 }
✗ every schema owner a worker or a gateway opens has one migration per version
- "migrations": 1, + "migrations": 2 (ios-source-data, android-source-data; the other 7 owners match)
Tests 5 failed (5)
Root cause
Defect. src/drivers/ios/source-data.ts:26 and src/drivers/android/source-data.ts:26 declare version: 1 but list two steps. migrateOwner (src/state/open.ts) runs migrations[from] only for from < version, so the CREATE UNIQUE INDEX step (index 1) never runs. ADR 0036 says one step per version. The symptom shows only when the per-kind lock fails, as on the slow lane.
Simplest fix
The maintainer's choice. Set both owners to version: 2. Step 2 first sets the older ready seed rows of a spec_key to making: it keeps the newest created_at, and on a tie the larger source_id. It then creates the index. Each driver's sweep then deletes those rows with their files. iOS: #removeLeftover runs simctl delete at the first listSources (create-core.ts:473). Android: #removeSource stops the emulator, then removes the folder and the row.
- version: 1,+ version: 2,+ `UPDATE <t> SET state = 'making' WHERE kind = 'seed' AND state = 'ready' AND EXISTS (+ SELECT 1 FROM <t> AS newer WHERE newer.kind = 'seed' AND newer.state = 'ready'+ AND newer.spec_key = <t>.spec_key AND (newer.created_at > <t>.created_at+ OR (newer.created_at = <t>.created_at AND newer.source_id > <t>.source_id)));
CREATE UNIQUE INDEX <t>_ready_seed ...`
pnpm test:changed: 2 failures, the same on main. A gateway already holds port 4700 on this host (#1382).
Alternatives rejected
Refuse the start while two ready seeds share a kind: the user would have to fix it by hand.
Delete the extra rows inside the step: leaves the simulator and emulator files with no row.
Risk
The guard test lists the owners by hand, copied from main.ts:268-279. An owner added later is not checked. The same check in migrateOwner would cover every owner.
Step 2 runs two statements in one exec. Check that a failed index rolls the demotion back inside the start transaction.
Fast track
Defect: yes
Fix tried: yes
Nothing public added or broken: yes
No ADR or rule changed: yes
One fix: no — refusing the start is a choice users would see; the maintainer picked demotion
Activity
V3RON commentedon Nov 6, 2026
Triage notes
Confirmed from the code (read only, nothing run):
src/drivers/ios/source-data.ts:3-27andsrc/drivers/android/source-data.ts:3-27:version: 1with two entries inmigrations(table, then the*_ready_seedpartial unique index).src/state/open.ts:159-161:migrateOwnerrunsmigrations[from]forfrominstored..version-1, so step 0 runs and step 1 never does. It is a defect, not a gap.ios_source_data_ready_seedorandroid_source_data_ready_seed, so nothing catches it today.Things to settle in the fix:
version: 2, with the index as step 2 (index[1]), as the issue says. Step 1 stays the same so databases already at version 1 pick it up.readyseed rows for onespec_key(as on the slow lane) makesCREATE UNIQUE INDEXfail. ThenmigrateOwnerrefuses the start with "could not move from version 1 to 2". The fix should decide whether step 2 first deletes or marks the extra rows, or whether that refusal is fine.openStateDatabase, or a test, checksmigrations.length === versionfor each owner, so the next owner can't make this mistake.Labels: added
platform:iosandplatform:android. Keptbug:new. The full rule 8 report (failing test, fast-track lines) andbug:readyare left to the triage-bug run or the maintainer.Written by an agent.
V3RON commentedon Nov 6, 2026
Reproduction
Confirmed: both seed tables lack the index, on a new
state.dband on one at version 1. Branchbug/1367-repro,src/daemon/state-owners.test.ts, "the seed tables' one-ready-seed-per-kind index (#1367)": five cases (two per platform, plus one over every owner). All five fail onmain.Root cause
Defect.
src/drivers/ios/source-data.ts:26andsrc/drivers/android/source-data.ts:26declareversion: 1but list two steps.migrateOwner(src/state/open.ts) runsmigrations[from]only forfrom < version, so theCREATE UNIQUE INDEXstep (index 1) never runs. ADR 0036 says one step per version. The symptom shows only when the per-kind lock fails, as on the slow lane.Simplest fix
The maintainer's choice. Set both owners to
version: 2. Step 2 first sets the olderreadyseed rows of aspec_keytomaking: it keeps the newestcreated_at, and on a tie the largersource_id. It then creates the index. Each driver's sweep then deletes those rows with their files. iOS:#removeLeftoverrunssimctl deleteat the firstlistSources(create-core.ts:473). Android:#removeSourcestops the emulator, then removes the folder and the row.pnpm test:changed: 2 failures, the same onmain. A gateway already holds port 4700 on this host (#1382).Alternatives rejected
Risk
main.ts:268-279. An owner added later is not checked. The same check inmigrateOwnerwould cover every owner.exec. Check that a failed index rolls the demotion back inside the start transaction.Fast track
Side findings
Written by an agent.
test: the seed-index migration test pins the kind and state filters a…
V3RON commentedon Nov 6, 2026
Delivery run
Merged: #1384 (#1367)
Parked: none
Waiting: none
Decided: none
Written by an agent.
fix(drivers): build the seed tables' one-ready-seed index in a versio…