Skip to content

Commit b8c062e

Browse files
committed
fix(db): enqueue artifact export on session_kind-only updates
session_kind is export-visible via the artifact manifest, but the artifact_sessions_update_queue trigger's change-detection list did not include it, so a session-kind-only update on an already-published session left its manifest stale. Add the column to the trigger and pin it with an export-queue test.
1 parent e114a45 commit b8c062e

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

internal/db/artifact_publication_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,6 +1909,26 @@ func TestArtifactPublicationQueueIgnoresSessionBookkeepingUpdates(t *testing.T)
19091909
assert.Empty(t, artifactExportQueueIDs(t, database))
19101910
}
19111911

1912+
// TestArtifactPublicationQueueEnqueuesSessionKindOnlyUpdate pins
1913+
// session_kind into the artifact_sessions_update_queue trigger's
1914+
// change-detection list: the field is export-visible via the manifest, so a
1915+
// session-kind-only update on an already-published session must re-enqueue
1916+
// its export.
1917+
func TestArtifactPublicationQueueEnqueuesSessionKindOnlyUpdate(t *testing.T) {
1918+
database := testDB(t)
1919+
seedArtifactOrigin(t, database)
1920+
require.NoError(t, database.UpsertSession(Session{
1921+
ID: "session", Project: "project", Machine: "local", Agent: "claude",
1922+
}))
1923+
clearArtifactExportQueue(t, database)
1924+
1925+
_, err := database.getWriter().Exec(
1926+
`UPDATE sessions SET session_kind = 'bg' WHERE id = 'session'`)
1927+
require.NoError(t, err)
1928+
assert.Equal(t, []string{"session"}, artifactExportQueueIDs(t, database),
1929+
"a session-kind-only update must re-enqueue the session for export")
1930+
}
1931+
19121932
// TestArtifactExportQueueStaysEmptyWithoutOrigin covers the deviation-1
19131933
// origin gate: an archive that has never created or adopted an artifact
19141934
// origin must never populate artifact_export_queue, regardless of how many

internal/db/db.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,6 +2311,7 @@ WHEN (
23112311
OLD.agent IS NOT NEW.agent OR
23122312
OLD.agent_label IS NOT NEW.agent_label OR
23132313
OLD.entrypoint IS NOT NEW.entrypoint OR
2314+
OLD.session_kind IS NOT NEW.session_kind OR
23142315
OLD.first_message IS NOT NEW.first_message OR
23152316
OLD.display_name IS NOT NEW.display_name OR
23162317
OLD.session_name IS NOT NEW.session_name OR

0 commit comments

Comments
 (0)